2013-11-19 2 views
0

Вот XML:Android - не layout_weight работает

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:background="@android:color/transparent" 
    android:minHeight="40dp" > 

    <LinearLayout 
     android:id="@+id/contentLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/separatorView" 
     android:weightSum="3" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/itemTitleLabel" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@null" 
      android:gravity="right" 
      android:lines="0" 
      android:paddingBottom="5dp" 
      android:paddingLeft="5dp" 
      android:paddingRight="5dp" 
      android:paddingTop="5dp" 
      android:textColor="@android:color/black" 
      android:textSize="16sp" 
      android:textStyle="bold" /> 

     <RelativeLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="2" 
      android:background="@android:color/white" > 

      <TextView 
       android:id="@+id/itemDetailsLabel" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:background="@null" 
       android:gravity="left" 
       android:lines="0" 
       android:paddingBottom="5dp" 
       android:paddingLeft="5dp" 
       android:paddingRight="5dp" 
       android:paddingTop="5dp" 
       android:textColor="@android:color/black" 
       android:textSize="16sp" 
       android:textStyle="normal" /> 

      <ImageView 
       android:id="@+id/itemAvailabilityImageView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:background="@null" 
       android:paddingBottom="5dp" 
       android:paddingLeft="5dp" 
       android:paddingRight="5dp" 
       android:paddingTop="5dp" 
       android:scaleType="centerInside" /> 
     </RelativeLayout> 
    </LinearLayout> 

    <View 
     android:id="@+id/separatorView" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_alignParentBottom="true" 
     android:background="@color/tab_bar_separator" /> 

</RelativeLayout> 

Это расположение строк в списке. Показан только последний вид. Единица с id = separatorView.

Update:

enter image description here

+0

Что вы пытаетесь реализовать, не могли бы вы разместить изображение? –

+0

@RishabhSrivastava добавил изображение –

ответ

-1

Надеется, что это помогает, если я получил свой вопрос прямо:

<View 
    android:layout_width="match_parent" 
    android:layout_height="2dp" 
    android:background="#000000" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Keyboard" /> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 
</LinearLayout> 

<View 
    android:layout_width="match_parent" 
    android:layout_height="2dp" 
    android:background="#000000" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Flash" /> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 
</LinearLayout> 

<View 
    android:layout_width="match_parent" 
    android:layout_height="2dp" 
    android:background="#000000" /> 

+0

Вы рисуете две строки в одном XML. Кроме того, я хочу, чтобы левая сторона имела фиксированную ширину, а также вид с правой стороны. Это решение не работает –

+0

проверить это сейчас ... вы знаете, что ваш вопрос не ясен, что именно то, что вы хотите реализовать. –

+0

В вашем макете отсутствует много вещей. Где находится ориентация макета. Почему есть два изображения, в то время как только один существует в строке. Позиция элементов неверна. –

0

Вы должны указать в своем последнем Просмотреть элемент (Разделитель)

android:layout_below="@id/ContentLayout" 

Чтобы убедиться, что разделительное устройство не будет совмещено с верхней частью RelativeLayout.

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