0

私のアプリは、画面上のボタンとテキストで構成されています。必要なのはそれだけなので、本当にシンプルです。

しかし、別の仮想電話でアプリをテストすると、見た目が異なります。今は画像を使用していないので、画像がドローアブルフォルダにあり、すべてが別のドローアブルフォルダに収容されているわけではない限り、問題にはならないと思います

しかし、すべてのSMARTPHONE画面に合うようにXMLをコーディングするにはどうすればよいですか。

XML:

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:padding="@dimen/padding_medium"
        android:text="@string/welsh_libs"
        android:textColor="#FF0066"
        android:textSize="30dip"
        android:textStyle="bold"
        tools:context=".WelshLibraries" />

</LinearLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="18dp"
        android:background="#6088A1"
        android:textColor="#FFFFFF"
        android:text="@string/news" />

    <Button
        android:id="@+id/button3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="18dp"
        android:background="#50C0E9"
        android:textColor="#000000"
        android:text="@string/find_lib" />

    <Button
        android:id="@+id/button4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="18dp"
        android:background="#6088A1"
        android:textColor="#FFFFFF"
        android:text="@string/free_res" />

    <Button
        android:id="@+id/button5"
        android:layout_width="285dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="18dp"
        android:background="#50C0E9"
        android:text="@string/ask_lib"
        android:textColor="#000000" />

    <Button
        android:id="@+id/button6"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="18dp"
        android:background="#6088A1"
        android:text="@string/find_book"
        android:textColor="#FFFFFF" />

    <Button
        android:id="@+id/button7"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="18dp"
        android:background="#50C0E9"
        android:text="@string/register"
        android:textColor="#000000" />

    <Button
        android:id="@+id/button8"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="18dp"
        android:background="#6088A1"
        android:text="@string/login"
        android:textColor="#FFFFFF" />

</LinearLayout>

<ImageView
    android:id="@+id/image1"
    android:layout_width="190dp"
    android:layout_height="0dip"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="70dp"
    android:layout_weight="1"
    android:contentDescription="@string/desc"
    android:src="@drawable/waglogo"
    android:visibility="visible" />

私は測定単位としてdpを使用していますが、使用できる唯一の単位であると理解しているので、pxs、ems、および%sを使用できるWebサイトを設計するのは好きではないことを知っています。

人々が提供できるどんな助けやリンクも大歓迎です。ありがとう、ダン

PSアプリの読み込み時に存在する8の下にボタンを追加したい場合は、下にスクロールする方法も探しています。何か案は?

4

1 に答える 1

1

まだ行っていない場合は、公式のAndroidDevelopersサイトを参照してください。さまざまな画面のサポートに関する記事があります:http://developer.android.com/guide/practices/screens_support.html

また、ボタンをスクロールする場合は、ボタンを含むLinearLayoutをScrollViewで囲みます。このようなもの:

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:padding="@dimen/padding_medium"
    android:text="@string/welsh_libs"
    android:textColor="#FF0066"
    android:textSize="30dip"
    android:textStyle="bold"
    tools:context=".WelshLibraries" />

   </LinearLayout>

<ScrollView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >

<Button
    android:id="@+id/button2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="18dp"
    android:background="#6088A1"
    android:textColor="#FFFFFF"
    android:text="@string/news" />

<Button
    android:id="@+id/button3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="18dp"
    android:background="#50C0E9"
    android:textColor="#000000"
    android:text="@string/find_lib" />

<Button
    android:id="@+id/button4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="18dp"
    android:background="#6088A1"
    android:textColor="#FFFFFF"
    android:text="@string/free_res" />

<Button
    android:id="@+id/button5"
    android:layout_width="285dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="18dp"
    android:background="#50C0E9"
    android:text="@string/ask_lib"
    android:textColor="#000000" />

<Button
    android:id="@+id/button6"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="18dp"
    android:background="#6088A1"
    android:text="@string/find_book"
    android:textColor="#FFFFFF" />

<Button
    android:id="@+id/button7"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="18dp"
    android:background="#50C0E9"
    android:text="@string/register"
    android:textColor="#000000" />

<Button
    android:id="@+id/button8"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="18dp"
    android:background="#6088A1"
    android:text="@string/login"
    android:textColor="#FFFFFF" />

 </LinearLayout>

 </ScrollView>

<ImageView
android:id="@+id/image1"
android:layout_width="190dp"
android:layout_height="0dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="70dp"
android:layout_weight="1"
android:contentDescription="@string/desc"
android:src="@drawable/waglogo"
android:visibility="visible" />
于 2012-07-24T14:44:07.110 に答える