2016-04-18 7 views
0

Я не мог сделать равную ширину Textview и linearlayout. Хотя в Textview задана ширина match_parent, но она не соответствует ширине родителя.Ширина текста не соответствует ширине родительского

я вижу эти сообщения: Android textView width not increasing

Android TextView does not expand to match parent

TextView width match drawableTop width

How to adjust text font size to fit textview

How to adjust text font size to fit textview

Но моя проблема не решена

enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="right|center_vertical" 
    android:layout_marginRight="@dimen/activity_horizontal_margin" 
    android:orientation="horizontal"> 

    <ImageView 
     android:id="@+id/thumbnail" 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:layout_marginRight="@dimen/activity_horizontal_margin" 
     android:src="@drawable/defaultpicpic" /> 

    <TextView 
     android:id="@+id/title" 
     style="@style/textViewItemStyle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingBottom="10dp" 
     android:paddingTop="10dp" /> 


</LinearLayout> 

ответ

1

я решить мою проблему с этим кодом :)

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="?android:attr/selectableItemBackground" 
    android:gravity="right|center_vertical" 
    android:orientation="vertical"> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:gravity="right|center_vertical" 
     android:orientation="horizontal"> 

     <ImageView 
      android:id="@+id/thumbnail" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:layout_marginRight="@dimen/activity_horizontal_margin" 
      android:src="@drawable/thumb" /> 

     <TextView 
      android:id="@+id/title" 
      style="@style/textViewItemStyle" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="16dp" /> 


    </LinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="2px" /> 


</LinearLayout> 
Смежные вопросы