2017-01-25 8 views
0

ボタンのヘルプに10dpの左右に余白が付いています。その後、ボタンhelpの下のTextView(水平の中央)の左にボタンテストを追加し、ボタンhelpの左に揃えます。アライメントに関するレイアウトの問題

問題は、ボタンのテストが正確にボタンhelpの右側にTextViewtest1のようにボタンhelpに整列されていないということです。

私は間違っていますか?私はthatsのヘルプボタンのちょうど背景を考える

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#ffffff" 
    > 

    <TextView 
     android:id="@+id/mid" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:text="1" 
     android:gravity="center" 
     /> 

    <Button 
     android:id="@+id/help" 
     android:text="Help" 
     android:layout_width="match_parent" 
     android:layout_marginTop="35dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_height="wrap_content"/> 

    <Button 
     android:id="@+id/test" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/help" 
     android:layout_marginTop="5dp" 
     android:background="#87CEFF" 
     android:text="Test" 
     android:layout_toLeftOf="@id/mid" 
     android:layout_alignLeft="@id/help" 
     /> 

    <TextView 
     android:id="@+id/test1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/mid" 
     android:layout_alignBottom="@id/test" 
     android:layout_alignTop="@id/test" 
     android:layout_alignRight="@id/help" 
     android:text="test1\ntest2" 
     android:gravity="center" 
     android:textColor="#0000ff" 
     android:background="#00cc00" 
     />  

</RelativeLayout> 
+0

を解決を願ってみてください。 ビューを表示するための期待値は –

+0

です。レイアウトの出力を見ると、ボタンのテストはボタンのヘルプに(一部のピクセルによって)正確には整列していません。テキストビューtest1はヘルプの右側にはありません。 – narb

+0

あなたの光はちょうどあなたに背景色を与える整列されていますヘルプボタン –

答えて

1

enter image description here

は、ここに私のレイアウトです。 カスタム背景を使用すると、すべてのスペースがいっぱいになります。

+0

これは変ですが、うまくいきます。ありがとう。 – narb

0

ラップテストボタンとテキストビューを相対レイアウトに配置し、それぞれ左右の親を一列に並べます。

+0

も面倒です。バックグラウンドの解決策は私の視点からは優れています。ありがとう。 – narb

0

ボタンテストに追加する必要があるのは、android:background = "@ android:color/darker_gray"またはいずれかの色です。デフォルトでアンドロイドはパディングパディングを提供しますボタンに。私は上記のコードでは、必要な変更を加えた

<Button 
    android:id="@+id/help" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="35dp" 
    android:background="@android:color/darker_gray" 
    android:text="Help" /> 

は、それはそれはあなたが何をしたいあなたの問題

関連する問題