2015-12-18 75 views
2

我再次遇到一些佈局問題。 我有一個有兩個TextViews和一個SwitchCompat的CardView佈局。 現在,開關處於開啓狀態,文本正確(垂直)。我想這個佈局相反的方式,例如像在一個應用程序的Android通知設置: Google Navigation Settings, that's how I want it to beTextView的SwitchCompat被推到視線之外

我的問題是,當我「把我目前的佈局圍繞」時,開關被推出時向右textView變得太長了。

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:paddingTop="20dp" 
    android:paddingBottom="20dp" 
    android:paddingRight="20dp" 
    android:paddingLeft="16dp" 
    android:id="@+id/relative"> 

    <android.support.v7.widget.SwitchCompat 
     android:id="@+id/switch_card" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="20dp" /> 

    <TextView 
     android:id="@+id/textView_title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/switch_card" 
     android:singleLine="false" 
     android:text="@string/title_card" 
     android:textColor="@color/text_black" 
     android:textSize="22dp" /> 

    <TextView 
     android:id="@+id/textView_reminder" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/textView_title" 
     android:layout_toRightOf="@id/switch_card" 
     android:paddingTop="10dp" 
     android:singleLine="false" 
     android:text="@string/reminder_card" 
     android:textColor="@color/text_grey" 
     android:textSize="18dp" /> 
</RelativeLayout> 

能否請你幫我改變我的佈局,它適合截圖的一個?我似乎無法自行解決問題。

回答

1

試試這個:招對準SwitchCompat到righParent放些餘量您正在使用,使他們不重疊SwitchCompat

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:paddingTop="20dp" 
     android:paddingBottom="20dp" 
     android:paddingRight="20dp" 
     android:paddingLeft="16dp" 
     android:id="@+id/relative"> 

     <android.support.v7.widget.SwitchCompat 
      android:id="@+id/switch_card" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_marginRight="20dp" /> 

     <TextView 
      android:id="@+id/textView_title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="40dp" 
      android:singleLine="false" 
      android:text="@string/title_card" 
      android:textColor="@color/text_black" 
      android:textSize="22dp" /> 

     <TextView 
      android:id="@+id/textView_reminder" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/textView_title" 
      android:layout_marginRight="40dp" 
      android:paddingTop="10dp" 
      android:singleLine="false" 
      android:text="@string/reminder_card" 
      android:textColor="@color/text_grey" 
      android:textSize="18dp" /> 

    </RelativeLayout> 

希望這是有幫助的

好運氣的TextView的!

+0

這真的很有幫助,非常感謝。看起來很不錯,但它確實有用。 – Eyntschl