0

レイアウトに問題があります。画像ボタンを垂直に配置したいのですが、さまざまな画面サイズで同じ外観にしたいのですが、ここに印刷画面がありますhttp://flic.kr/p/fwEZn1

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/chalk"
android:gravity="center|fill_vertical"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="1000dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="104dp" >

    <ImageButton
        android:id="@+id/m"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="62dp"
        android:layout_weight="1.30"
        android:background="@android:color/transparent"
        android:contentDescription="exam schedule button"
        android:onClick="ex"
        android:src="@drawable/exam" />

    <ImageButton
        android:id="@+id/cl"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="60dp"
        android:background="@android:color/transparent"
        android:contentDescription="classes button"
        android:onClick="cl"
        android:src="@drawable/list1" />

    <ImageButton
        android:id="@+id/lec"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.24"
        android:background="@android:color/transparent"
        android:contentDescription="lecture section button"
        android:onClick="lc"
        android:src="@drawable/sylla" />

    <ImageButton
        android:id="@+id/gr"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="20dp"
        android:layout_weight="3.36"
        android:background="@android:color/transparent"
        android:contentDescription="group button"
        android:onClick="gr"
        android:src="@drawable/group" />
      </LinearLayout>

    <LinearLayout
  android:id="@+id/linearLayout2"
  android:layout_width="1000dp"
  android:layout_height="wrap_content"
  android:layout_alignParentLeft="true"
  android:layout_below="@+id/linearLayout1"
  android:layout_marginTop="123dp" >

  <ImageButton
      android:id="@+id/kl"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginRight="74dp"
      android:layout_weight="0.69"
      android:background="@android:color/transparent"
      android:contentDescription="calendar button"
      android:onClick="kl"
      android:src="@drawable/calendar" />

     <ImageButton
      android:id="@+id/d"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_alignTop="@+id/pd"
      android:layout_marginRight="84dp"
      android:layout_weight="0.38"
      android:background="@android:color/transparent"
      android:contentDescription="Schedule button"
      android:onClick="sk"
      android:src="@drawable/sked" />

     <ImageButton
      android:id="@+id/pd"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/button1"
      android:layout_alignTop="@+id/an"
      android:layout_weight="0.16"
      android:background="@android:color/transparent"
      android:contentDescription="podcast button"
      android:onClick="pd"
      android:src="@drawable/podcast" />

  <ImageButton
      android:id="@+id/an"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignTop="@+id/kl"
      android:layout_marginLeft="60dp"
      android:layout_toRightOf="@+id/kl"
      android:layout_weight=".92"
      android:background="@android:color/transparent"
      android:contentDescription="announcement button"
      android:onClick="an"
      android:src="@drawable/announce" />
  </LinearLayout>
  <ImageButton
  android:id="@+id/button1"
  android:layout_width="53dp"
  android:layout_height="40dp"
  android:layout_alignParentBottom="true"
  android:layout_alignParentLeft="true"
  android:layout_marginBottom="106dp"
  android:layout_marginLeft="342dp"
  android:layout_weight="0.38"
  android:background="@android:color/transparent"
  android:contentDescription="logout button"
  android:onClick="logout"
  android:src="@drawable/logout"
  android:text="Logout" />
 </RelativeLayout>

だから基本的には画像ボタンの配置を直したい。これどうやってするの?ドローアブル フォルダーごとに画像のサイズを変更する必要がありますか?

4

2 に答える 2

0

簡単な解決策があります。すべての画面サイズでレイアウトが同じに見えるようにしたいのですが、layout_height、margin、padding などにハードコードされた値を使用しています。この目的のために、values フォルダーの dimens.xml を使用します。すべての画面の値を指定し、リソース フォルダーに次のフォルダーを作成します。

   values-small
   values-normal(The default values folder is values-normal)       
   values-large
   values-xlarge(You can use values-sw600 for tablets after Android 3.2)

これらすべてのフォルダーで、マージン、高さ、幅、パディングなどをdpで指定するdimens.xmlを作成し、フォントサイズを指定することもできます。お役に立てれば!

于 2013-08-18T08:31:55.987 に答える
0

「見る」と言うとき、すべての画面サイズで同じサイズを意味していましたか? これを行う可能な方法は、xml で ImageButton に設定することです。

    scaleType="centerInside"

画像ボタンのすべての重みを1に設定します

    layout_weight="1"

そして、すべてのボタンを垂直に設定したい場合は、 LinearLayout で宣言します

    android:orientation="vertical"

ところで、複数の画面に収まるように、すべてのドローアブルに異なる画像を設定することは常に良い習慣です。

于 2013-08-18T08:25:56.980 に答える