2016-03-09 2 views
-2

Как написать && в XML? Я хочу использовать его для кнопки. Я хочу, чтобы использовать его как это:Как написать «&&» в XML?

android:layout_below="@id/textview && @id/anothertextview" 

То, что я пытаюсь это

Я фрагмент с несколькими вкладками, а некоторые из этих вкладок имеют TextView-TextView-Button (под друг друга), а некоторые из них имеют только Textview-Button. Фрагменты только с Textview-Buttons хороши, но те, у которых есть 2 Textviews, нет. Кнопка появляется на втором Textview, а не ниже. Есть ли способ сказать, что он остается под последним виджетами? Если это Текст1-Text2-Button, то ниже Текст2 если это Текст1-Button, то чуть ниже Text1 и т.д.

Вот мой XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#006400"> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent"> 
     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="New Text" 
     android:id="@+id/handling" 
     android:textColor="#ffffff" 
     android:textSize="20dp" /> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="200dp" 
     android:id="@+id/stilling" 
     android:layout_below="@id/handling" 
     android:visibility="gone" 
     android:layout_gravity="center_vertical" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:textAlignment="center" 
       android:text="New Text" 
       android:id="@+id/arabisk" 
       android:visibility="gone" 
       android:layout_below="@id/stilling" 
       android:layout_gravity="center" 
       android:textSize="18dp" 
       android:textColor="#ff0000" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:layout_below="@id/stilling" 
       android:orientation="horizontal"> 

       <Button android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text=">" 
        android:visibility="gone" 
        android:id="@+id/start" 
        android:layout_weight="1" 
        /> 

       <Button android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:visibility="gone" 
        android:text="||" 
        android:id="@+id/stop" 
        android:layout_weight="1" 
        /> 
      </LinearLayout> 


     </RelativeLayout> 

    </ScrollView> 

</LinearLayout> 
+0

и заменить & –

+0

@NarendraBaratam, но это не поддерживается системой компоновки. – EpicPandaForce

+0

'android: layout_below' может иметь только 1 вид, вы не можете' и 'его, вам нужно построить свой макет таким образом, использовать другие параметры, например (' android: layout_above') использовать его с 'anothertextview' например, чтобы получить нужный результат – Yazan

ответ

0

Изменение XML, как показано ниже. Замените RelativeLayout с помощью LinearLayout.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="#006400"> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent"> 

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

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="New Text" 
       android:id="@+id/handling" 
       android:textColor="#ffffff" 
       android:textSize="20dp" /> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:id="@+id/stilling" 
       android:visibility="gone" 
       android:layout_gravity="center_vertical" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:textAlignment="center" 
       android:text="New Text" 
       android:id="@+id/arabisk" 
       android:visibility="visible" 
       android:layout_gravity="center" 
       android:textSize="18dp" 
       android:textColor="#ff0000" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:orientation="horizontal"> 

       <Button android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text=">" 
         android:visibility="visible" 
         android:id="@+id/start" 
         android:layout_weight="1"/> 

       <Button android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:visibility="visible" 
         android:text="||" 
         android:id="@+id/stop" 
         android:layout_weight="1"/> 
      </LinearLayout> 


     </LinearLayout> 

    </ScrollView> 

</LinearLayout> 
Смежные вопросы