2017-02-17 5 views
0

Я хочу, чтобы отобразить один ImageView, 2 TextViews и один Rating Bar в одном узле в пользовательский список адаптера, но обрезать его, когда я запускаю код здесь XML-код пользовательского списка Here is the picture of listAndroid: как настроить пользовательские списки?

custom_list.xml

?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<TableRow> 
    <ImageView 
     android:id="@+id/img" 
     android:layout_width="50dp" 
     android:layout_height="50dp"/> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="Name" 
     android:id="@+id/tv_name" 
     android:layout_column="2" /> 

</TableRow> 

<TableRow 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TextView 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:id="@+id/tv_deal" 
     android:layout_column="2" 
     android:text="deals" /> 
</TableRow> 

<TableRow 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <RatingBar android:id="@+id/rb_rating" 
     android:layout_column="2" /> 
</TableRow> 

+1

Любые причины, по которым вы используете 'TableLayout' вместо' RelativeLayout'? ... также кажется, что проблема не здесь, а в макете, где у вас есть listview. – Selvin

+0

Является ли Relative Layout подобным образом в пользовательском макете? – SFAH

+0

да, это работает. Опубликовать свой список Listview или Recyclerview –

ответ

1

Использование ниже XML для ListView Пункт:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:id="@+id/img" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" /> 

    <TextView 
     android:id="@+id/tv_name" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/img" 
     android:text="Name" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <TextView 
     android:id="@+id/tv_deal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/img" 
     android:text="deals" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 


    <RatingBar 
     android:id="@+id/rb_rating" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/tv_deal" /> 
</RelativeLayout> 
+0

Да, вы были правы 'RealtiveLayout' более эффективен, чем таблица Layout – SFAH