-1

Я понимаю, что это обсуждалось много раз, но я не могу найти решение. Я специально отметил все в цветах. Это AlertDialog.Шрифт в TextView в горизонтальном LinearLayout не соответствует высоте родителя?

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="match_parent" 
    android:background="@drawable/dialogs_background_gradient" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:id="@+id/dialNewGroupCustomNameLay" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/customNameTextView" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="0.3" 
      android:gravity="left|center_vertical" 
      android:paddingLeft="10dp" 
      android:text="@string/group_custom_name_label" 
      android:textColor="@color/white" 
      android:textSize="15dp" /> 

     <EditText 
      android:id="@+id/newGrNameEditText" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="center_vertical" 
      android:layout_weight="0.7" 
      android:textColor="@color/white" 
      android:textCursorDrawable="@null" /> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/dialNewGroupDefinedLangsLay" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:layout_margin="3dp" 
      android:background="@color/white" /> 

     <LinearLayout 
      android:id="@+id/newGrDialLangFrom" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="0.6" 
      android:orientation="vertical"></LinearLayout> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:layout_margin="3dp" 
      android:background="@color/white" /> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/newGrNameLay" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/purple" 
     android:orientation="horizontal" 
     android:paddingBottom="30dp" 
     android:paddingTop="10dp"> 

     <TextView 
      android:id="@+id/groupNameTextView" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="0.3" 
      android:background="@color/red" 
      android:gravity="left|center_vertical" 
      android:paddingLeft="10dp" 
      android:text="@string/group_name_label" 
      android:textColor="@color/white" 
      android:textSize="15dp" /> 

     <TextView 
      android:id="@+id/newGrNameTextView" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="0.7" 
      android:background="@color/green" 
      android:gravity="left|center_vertical" 
      android:paddingLeft="10dp" 
      android:paddingBottom="10dp" 
      android:text="@string/group_name_label" 
      android:textColor="@color/white" 
      android:textSize="17dp" /> 
    </LinearLayout> 

</LinearLayout> 

Добавлен полный XML. Также необходимо учитывать, что LinearLayout находится в AlertDialog.

+0

Просто удалите 'android: paddingBottom =" 30dp "из вашего TextViews. Более того, вам действительно не нужно ** 2 ** вложенное LinearLayout (плохое для выступлений). A ** single ** RelativeLayout более эффективен. –

+0

Я проверил ваш макет. Это показывает правильность моей системы. можете ли вы разместить полный xml? – Nikhil

ответ

0

Высота текста + заполнение приведет к высоте Teaxtbox (match_parent).

0

Ваш LinearLayout получает высоту от своих детей:

android:layout_height="wrap_content" 

и дети получают высоту от родительского LinearLayout:

android:layout_height="match_parent" 

Это ошибка. У вас должно быть место, где высота указана.

+0

Я понимаю, как исправить в моем случае? – JDev

+0

Попробуйте установить 'android: layout_height =" 100dp "' в newGrNameLay LinearLayout. –

0

Я удалил все прокладки и края нижней и верхней. Добавлен снизу небольшой вид.

enter image description here

<View 
    android:layout_width="match_parent" 
    android:layout_height="10dp" 
    android:layout_margin="3dp"/> 

Он выглядит лучше.