2016-10-22 28 views
0

下面的代码生成结果的蓝图:意见线性布局不正确对齐

<?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="@drawable/marker_shape"> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/marker_header"> 

     <TextView 
      android:id="@+id/widget_1_header_from" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:ellipsize="end" 
      android:maxLines="1"/> 

     <Button 
      android:id="@+id/widget_1_refresh" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:background="@drawable/quantum_ic_refresh_white_24"/> 

    </LinearLayout> 

    <ListView 
     android:id="@+id/widget_1_list" 
     android:footerDividersEnabled="false" 
     android:headerDividersEnabled="false" 
     android:layout_width="match_parent" 
     android:dividerHeight="0dp" 
     android:layout_height="wrap_content"> 

    </ListView> 

</LinearLayout> 

正如你可以看到:TextView的被显示在按钮下方。他们需要彼此相邻。我该如何解决?

blueprint

回答

0

你有2种选择:

  1. 更改按钮的高度wrap_content

或:

  • 改变您的TextView高度match_parent
  • +0

    不知道为什么,但它的工作。谢谢! – Dendrowen