0

私はRelativeLayoutを使ってレイアウトを作成します。ここで私は以下のようなレイアウトを設計します。私はアンドロイドスタジオを使用しています。一部のボタンがAndroidのRelativeLayoutに表示されない

enter image description here

これは私のレイアウトコードで、

<?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="@android:color/white"> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/content24" 
     android:id="@+id/step19textView" 
     android:textSize="18dp" 
     android:textAlignment="center" 
     android:paddingRight="10dp" 
     android:paddingLeft="10dp" 
     android:paddingBottom="10dp" 
     android:paddingTop="10dp" 
     android:layout_marginTop="32dp" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 
<HorizontallScrollBar> 
    <LinearLayout 
      Orienteation= "horizontal";> 
    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="39dp" 
     android:layout_height="wrap_content" 
     android:text="1" 
     android:id="@+id/step19button1" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:background="@drawable/button_border" 
     android:layout_below="@+id/step19textView" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_marginTop="50dp" /> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="39dp" 
     android:layout_height="wrap_content" 
     android:text="2" 
     android:id="@+id/step19button2" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignTop="@+id/step19button1" 
     android:layout_toRightOf="@+id/step19button1" 
     android:layout_toEndOf="@+id/step19button1" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="39dp" 
     android:layout_height="wrap_content" 
     android:text="3" 
     android:id="@+id/step19button3" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button2" 
     android:layout_toRightOf="@+id/step19button2" 
     android:layout_toEndOf="@+id/step19button2" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="39dp" 
     android:layout_height="wrap_content" 
     android:text="4" 
     android:id="@+id/step19button4" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:textColor="@android:color/white" 
     android:layout_alignBottom="@+id/step19button3" 
     android:layout_toRightOf="@+id/step19button3" 
     android:layout_toEndOf="@+id/step19button3" 
     android:background="@drawable/button_border_5"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="39dp" 
     android:layout_height="wrap_content" 
     android:text="5" 
     android:id="@+id/step19button5" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button4" 
     android:layout_toRightOf="@+id/step19button4" 
     android:layout_toEndOf="@+id/step19button4" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="39dp" 
     android:layout_height="wrap_content" 
     android:text="6" 
     android:id="@+id/step19button6" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button5" 
     android:layout_toRightOf="@+id/step19button5" 
     android:layout_toEndOf="@+id/step19button5" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="39dp" 
     android:layout_height="wrap_content" 
     android:text="7" 
     android:id="@+id/step19button7" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button6" 
     android:layout_toRightOf="@+id/step19button6" 
     android:layout_toEndOf="@+id/step19button6" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="39dp" 
     android:layout_height="wrap_content" 
     android:text="8" 
     android:id="@+id/step19button8" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button7" 
     android:layout_toRightOf="@+id/step19button7" 
     android:layout_toEndOf="@+id/step19button7" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="39dp" 
     android:layout_height="wrap_content" 
     android:text="9" 
     android:id="@+id/step19button9" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button8" 
     android:layout_toRightOf="@+id/step19button8" 
     android:layout_toEndOf="@+id/step19button8" 
     android:background="@drawable/button_border"/> 
    </LinearLayout> 
    </HorizontalScrollBar> 

    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="20dp" 
     android:id="@+id/step19editText" 
     android:paddingLeft="10dp" 
     android:layout_below="@+id/step19button1" 
     android:layout_alignLeft="@+id/step19button1" 
     android:layout_alignStart="@+id/step19button1" 
     android:layout_marginTop="20dp" /> 

    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="20dp" 
     android:id="@+id/step19editText2" 
     android:layout_alignTop="@+id/step19editText" 
     android:layout_centerHorizontal="true" /> 

    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="20dp" 
     android:id="@+id/step19editText3" 
     android:paddingRight="10dp" 
     android:layout_alignTop="@+id/step19editText2" 
     android:layout_alignRight="@+id/step19button9" 
     android:layout_alignEnd="@+id/step19button9" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/content25" 
     android:id="@+id/step19textView2" 
     android:textAlignment="textStart" 
     android:textSize="18dp" 
     android:paddingLeft="10dp" 
     android:layout_alignTop="@+id/step19textView4" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/content26" 
     android:id="@+id/step19textView4" 
     android:textSize="18dp" 
     android:textAlignment="center" 
     android:layout_alignTop="@+id/step19textView5" 
     android:layout_centerHorizontal="true" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/content27" 
     android:id="@+id/step19textView5" 
     android:textSize="18dp" 
     android:textAlignment="textEnd" 
     android:paddingRight="10dp" 
     android:layout_below="@+id/step19editText3" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" /> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text=" Next " 
     android:textSize="18dp" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp" 
     android:id="@+id/step19nextbutton" 
     android:layout_marginTop="59dp" 
     android:textColor="@android:color/white" 
     android:background="@drawable/button_border_5" 
     android:layout_below="@+id/step19textView4" 
     android:layout_centerHorizontal="true" /> 

</RelativeLayout> 

私はサムスンギャラクシーSデュオ3http://www.gsmarena.com/samsung_galaxy_s_duos_3-6662.php)でこれを実行しようとする設計でありながら、8つの& 9のボタンが表示されませんそのように見える。

すべてのボタンが画像のように見えるようにします。 これについてのアイデアはありますか?

ありがとうございます。

+2

にXMLあなたを置き換え、これを試してみてください。それは画面から境界から外れています。 –

+0

@ShreeKrishna:ここで水平スクロールビューを使用できますか? – Barrier

+1

@Barrier水平スクロールビュー –

答えて

1

は自分のマージン、パディングを管理したり、スクロールビューを使用して、この

<?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="@android:color/white"> 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/content24" 
    android:id="@+id/step19textView" 
    android:textSize="18dp" 
    android:textAlignment="center" 
    android:paddingRight="10dp" 
    android:paddingLeft="10dp" 
    android:paddingBottom="10dp" 
    android:paddingTop="10dp" 
    android:layout_marginTop="32dp" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

<LinearLayout 
    android:id="@+id/llParent" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/step19textView" 
    android:layout_marginTop="50dp" 
    android:orientation="horizontal"> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="1" 
     android:id="@+id/step19button1" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_weight="1" 
     android:background="@drawable/button_border" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     /> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="2" 
     android:id="@+id/step19button2" 
     android:layout_weight="1" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignTop="@+id/step19button1" 
     android:layout_toRightOf="@+id/step19button1" 
     android:layout_toEndOf="@+id/step19button1" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="3" 
     android:layout_weight="1" 
     android:id="@+id/step19button3" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button2" 
     android:layout_toRightOf="@+id/step19button2" 
     android:layout_toEndOf="@+id/step19button2" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="4" 
     android:id="@+id/step19button4" 
     android:textSize="13dp" 
     android:layout_weight="1" 
     android:layout_marginLeft="3dp" 
     android:textColor="@android:color/white" 
     android:layout_alignBottom="@+id/step19button3" 
     android:layout_toRightOf="@+id/step19button3" 
     android:layout_toEndOf="@+id/step19button3" 
     android:background="@drawable/button_border_5"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="5" 
     android:id="@+id/step19button5" 
     android:textSize="13dp" 
     android:layout_weight="1" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button4" 
     android:layout_toRightOf="@+id/step19button4" 
     android:layout_toEndOf="@+id/step19button4" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="6" 
     android:id="@+id/step19button6" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_weight="1" 
     android:layout_alignBottom="@+id/step19button5" 
     android:layout_toRightOf="@+id/step19button5" 
     android:layout_toEndOf="@+id/step19button5" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="7" 
     android:id="@+id/step19button7" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_weight="1" 
     android:layout_alignBottom="@+id/step19button6" 
     android:layout_toRightOf="@+id/step19button6" 
     android:layout_toEndOf="@+id/step19button6" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="8" 
     android:layout_weight="1" 
     android:id="@+id/step19button8" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button7" 
     android:layout_toRightOf="@+id/step19button7" 
     android:layout_toEndOf="@+id/step19button7" 
     android:background="@drawable/button_border"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="9" 
     android:layout_weight="1" 
     android:id="@+id/step19button9" 
     android:textSize="13dp" 
     android:layout_marginLeft="3dp" 
     android:layout_alignBottom="@+id/step19button8" 
     android:layout_toRightOf="@+id/step19button8" 
     android:layout_toEndOf="@+id/step19button8" 
     android:background="@drawable/button_border"/> 
</LinearLayout> 


<EditText 
    android:layout_width="wrap_content" 
    android:layout_height="20dp" 
    android:id="@+id/step19editText" 
    android:paddingLeft="10dp" 
    android:layout_below="@+id/llParent" 
    android:layout_alignLeft="@+id/llParent" 
    android:layout_alignStart="@+id/llParent" 
    android:layout_marginTop="20dp" /> 

<EditText 
    android:layout_width="wrap_content" 
    android:layout_height="20dp" 
    android:id="@+id/step19editText2" 
    android:layout_alignTop="@+id/step19editText" 
    android:layout_centerHorizontal="true" /> 

<EditText 
    android:layout_width="wrap_content" 
    android:layout_height="20dp" 
    android:id="@+id/step19editText3" 
    android:paddingRight="10dp" 
    android:layout_alignTop="@+id/step19editText2" 
    android:layout_alignRight="@+id/llParent" 
    android:layout_alignEnd="@+id/llParent" /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/content25" 
    android:id="@+id/step19textView2" 
    android:textSize="18dp" 
    android:paddingLeft="10dp" 
    android:layout_alignTop="@+id/step19textView4" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/content26" 
    android:id="@+id/step19textView4" 
    android:textSize="18dp" 
    android:textAlignment="center" 
    android:layout_alignTop="@+id/step19textView5" 
    android:layout_centerHorizontal="true" /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/content27" 
    android:id="@+id/step19textView5" 
    android:textSize="18dp" 

    android:paddingRight="10dp" 
    android:layout_below="@+id/step19editText3" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" /> 

<Button 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text=" Next " 
    android:textSize="18dp" 
    android:paddingLeft="20dp" 
    android:paddingRight="20dp" 
    android:id="@+id/step19nextbutton" 
    android:layout_marginTop="59dp" 
    android:textColor="@android:color/white" 
    android:background="@drawable/button_border_5" 
    android:layout_below="@+id/step19textView4" 
    android:layout_centerHorizontal="true" /> 

</RelativeLayout> 
+0

ありがとう、ありがとう。これはうまくいった。あなたは私の大きな問題を解決します。 – Barrier

+0

@Barrier always wc ... –

+0

あなたはこれを欲しがっていますか?http://stackoverflow.com/questions/37316676/what-are-the-correct-layout-folders-for-multi-screens-in- android –

1

明らかに画面サイズnexus 4は、samsung galaxy duos 30.7"より大きくなります。だからあなたのボタンのいくつかがスクリーンから境界線から出て来たのです。だから私は

<HorizontalScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ...> 
     Here are your buttons 
</HorizontalScrollView> 

OR

どちらかLinearLayoutを使用してhereを説明したようweightweight_sum属性とそれらを管理するようにHorizontalScrollViewでそれらをラップすることをお勧めします。

1

この問題を解決するには2つの方法があります。サンプルこの

<LinearLayout 
    android:orientation = "horizontal" 
    android:weightSum = "9"> 
    <Button 
     android:layout_weight="1"> 
    <Button 
     android:layout_weight="2"> 
    ... 
    ... 
    <!--Create 9 button with layout_weight = 1 --> 
</LinearLayout> 

ようになる

使用してレイアウトの重み

この基本的に等しいサイズの9つのボタンで水平方向のLinearLayoutを作成します。したがって、これらのボタンは、LinearLayoutのサイズの1/9を占めます。

もう一つの方法は、水平方向のスクロール可能なビュー

水平スクロールビューHorizo​​ntalScrollView、または水平であるRecyclerView、またはあなた自身のViewGroup(水平)水平、または作ることができListViewコントロールすることができ

を作ることです

この場合、ボタンに独自の幅を設定することができ、これらのボタンをスクロールすることができます。

Horizo​​ntalScrollViewを使用することをお勧めします。私たちは画面の幅がわからないため、デバイスの画面の占有量が少ないと、ボタンが押しつぶされ、良いUIを残さないでしょう。

1
<LinearLayout 
       Orienteation= "horizontal";> 
     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
android:layout_weight = 1 

      android:text="1" 
      android:id="@+id/step19button1" 
      android:textSize="13dp" 
      android:layout_marginLeft="3dp" 
      android:background="@drawable/button_border" 
      android:layout_below="@+id/step19textView" 
      android:layout_alignParentLeft="true" 
      android:layout_weight = 1 
      android:layout_alignParentStart="true" 
      android:layout_marginTop="50dp" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:text="2" 
      android:id="@+id/step19button2" 
      android:layout_weight = 1 
      android:textSize="13dp" 
      android:layout_marginLeft="3dp" 
      android:layout_alignTop="@+id/step19button1" 
      android:layout_toRightOf="@+id/step19button1" 
      android:layout_toEndOf="@+id/step19button1" 
      android:background="@drawable/button_border"/> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:text="3" 
      android:id="@+id/step19button3" 
      android:textSize="13dp" 
      android:layout_weight = 1 
      android:layout_marginLeft="3dp" 
      android:layout_alignBottom="@+id/step19button2" 
      android:layout_toRightOf="@+id/step19button2" 
      android:layout_toEndOf="@+id/step19button2" 
      android:background="@drawable/button_border"/> 

.... .....

関連する問題