-1

두 개의 텍스트보기를 하단 오른쪽에 고정시키고 목록보기 위에 유지하려고합니다. listview가 비어있는 경우 오른쪽 아래로 고정하고 싶지만 목록보기에 일부 항목을 추가하면이 코드로 textview가 사라집니다. Layout ImagetextView를 하단 오른쪽으로 설정하십시오.

<?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"> 
    <LinearLayout 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/relativeLayout1"> 
     <Button 
      android:text="Fechar Comanda" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnFecharComanda" /> 
     <Button 
      android:text="Extrato" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnExtrato" /> 
     <Button 
      android:text="Enviar Cozinha" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnEnviarCozinha" /> 
     <Button 
      android:text="Anterior" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnAnterior" /> 
    </LinearLayout> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/linearLayout1" 
     android:weightSum="100"> 
     <ListView 
      android:id="@+id/sportsList" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:entries="@array/primeira" 
      android:layout_weight="33" /> 
     <ListView 
      android:id="@+id/sportsList_1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:entries="@array/segunda" 
      android:layout_weight="34" /> 
     <LinearLayout 
      android:orientation="vertical" 
      android:layout_weight="33" 
      android:id="@+id/linearLay123123" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:weightSum="100"> 
      <ListView 
       android:id="@+id/sportsList_2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:entries="@array/terceira" /> 
      <LinearLayout 
       android:orientation="vertical" 
       android:id="@+id/odkjfs" 
       android:layout_width="match_parent" 
       android:layout_height="100px" 
       android:gravity="bottom"> 
       <TextView 
        android:text="Total" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/textView2" 
        android:gravity="end" 
        android:layout_marginRight="10dp" /> 
       <TextView 
        android:text="R$15" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:id="@+id/textView1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="end" 
        android:layout_marginRight="10dp" 
        android:layout_marginBottom="10dp" /> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

답변

0

그래서 당신은 당신의 문제의 해결책이 무엇 ReleativeLayout와 귀하의 질문에, 태그했습니다.

<?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"> 
    <LinearLayout 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/relativeLayout1"> 
     <Button 
      android:text="Fechar Comanda" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnFecharComanda" /> 
     <Button 
      android:text="Extrato" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnExtrato" /> 
     <Button 
      android:text="Enviar Cozinha" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnEnviarCozinha" /> 
     <Button 
      android:text="Anterior" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnAnterior" /> 
    </LinearLayout> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/linearLayout1" 
     android:weightSum="100"> 
     <ListView 
      android:id="@+id/sportsList" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:entries="@array/primeira" 
      android:layout_weight="33" /> 
     <ListView 
      android:id="@+id/sportsList_1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:entries="@array/segunda" 
      android:layout_weight="34" /> 
     <RelativeLayout 
      android:layout_weight="33" 
      android:id="@+id/linearLay123123" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <ListView 
       android:id="@+id/sportsList_2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_above="@+id/odkjfs" 
       android:entries="@array/terceira" /> 
      <LinearLayout 
       android:orientation="vertical" 
       android:id="@+id/odkjfs" 
       android:layout_width="match_parent" 
       android:layout_height="100px" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentRight="true"> 
       <TextView 
        android:text="Total" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/textView2" 
        android:gravity="end" 
        android:layout_marginRight="10dp" /> 
       <TextView 
        android:text="R$15" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:id="@+id/textView1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="end" 
        android:layout_marginRight="10dp" 
        android:layout_marginBottom="10dp" /> 
      </LinearLayout> 
     </RelativeLayout> 
    </LinearLayout> 
</LinearLayout> 

당신 아이디의이 그래서 조언을 기억하는 것은 매우 어려운 : 당신은 당신이 항상 오른쪽 아래에 odkjfs을 원하고 ListViewsportsList_2 그 위에 것을, 당신의 linearLay123123RelativeLayout로 변경하고 레이아웃 시스템을 알려줄 필요 당신이 그들을 바꿀 수 있습니다.

하지만 위의 레이아웃을 세분화 할 수 있습니다. 당신은 2 개의 행을 가진 바깥 쪽 레이아웃을 가지고 있습니다. 하단에는 세 개의 열이 있습니다. 당신이 바꾸고 싶었던 부분은 가장 오른쪽에있는 열이므로 그 밑에 뭔가가 남아 있습니다.

여기서 가장 쉬운 방법은 LinearLayout에서 RelativeLayout으로 변경하는 것입니다. 이름에서 알 수 있듯이보기가 서로 상대적으로 정렬하기가 훨씬 쉽기 때문입니다.

따라서 RelativeLayout으로 변경 한 후 ListView에 상단에 맞춰야한다고 말합니다. 그리고 높이를 아래 내용보다 높게 조정해야합니다.

android:layout_alignParentTop="true" 
android:layout_above="@+id/odkjfs" 

그런 다음 LinearLayout있는 당신은 오른쪽 아래에있을 싶었다. 오른쪽으로 조정하여 아래쪽으로 조정해야합니다.

android:layout_alignParentBottom="true" 
android:layout_alignParentRight="true" 

간단함.