0

У меня есть один relativeLayout и три вида внутри RelativeLayout. Там видны места друг на друга.Обратные схемы внутри RelativeLayout программно

<RelativeLayout 
    android:id="@+id/includelayoutgroup" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <View xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/transparentColorView" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:clickable="true" 
     android:visibility="visible" /> 


    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/keyboard_main_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:visibility="visible"> 

     <include 
      layout="@layout/transfer_keyboard_fragment" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </RelativeLayout> 


    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/finalRequestView" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:clickable="true" 
     android:visibility="visible"> 

     <include 
      layout="@layout/fragment_transfer_new_version_container_child" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

    </RelativeLayout> 
</RelativeLayout> 

Возможно ли изменить положение моего зрения? Я имею в виду, что в моем коде последний макет равен finalRequestView, а при нажатии кнопки «Я» на мой последний вид в первой позиции и на другом представлении на моем представлении Как я могу решить эту проблему?

ответ

0

Я пытаюсь обратить макет следуя демо & он работает, как вы хотите, пожалуйста, посмотрите

enter image description here

ReverseLayout.java

public class ReverseLayout extends AppCompatActivity { 

    LinearLayout llRoot; 
    Button btReverseLayout; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.reverse_layout); 

     llRoot = (LinearLayout) findViewById(R.id.llRoot); 
     btReverseLayout = (Button) findViewById(R.id.btReverseLayout); 

     btReverseLayout.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       ArrayList<View> alViews = new ArrayList<View>(); 
       for (int i = llRoot.getChildCount() - 1; i >= 0; i--) { 
        View view = llRoot.getChildAt(i); 
        llRoot.removeViewAt(i); 
        alViews.add(view); 
       } 

       for (int j = 0; j < alViews.size(); j++) { 
        llRoot.addView(alViews.get(j)); 
       } 
      } 
     }); 
    } 
} 

расположение reverse_layout.xml файл

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_6" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.tosc185.testproject.Activity6"> 

    <LinearLayout 
     android:id="@+id/llRoot" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#FF0000" 
      android:gravity="center" 
      android:orientation="vertical" 
      android:padding="15dp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="1" 
       android:textSize="16dp" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#00FF00" 
      android:gravity="center" 
      android:orientation="vertical" 
      android:padding="15dp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="2" 
       android:textSize="16dp" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#0000FF" 
      android:gravity="center" 
      android:orientation="vertical" 
      android:padding="15dp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="3" 
       android:textSize="16dp" /> 
     </LinearLayout> 

    </LinearLayout> 

    <Button 
     android:id="@+id/btReverseLayout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:text="Reverse Layout" /> 
</RelativeLayout> 
+0

спасибо ваше внимание. Вы используете LinearLayout и o ориентация - вертикальная. Можно ли использовать ваш код с RelativeLayout? где каждый взгляд на каждую точку? – BekaKK

Смежные вопросы