Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 水平线布局中文本视图中的字体与父高度不匹配?_Android_Android Layout_Android Linearlayout_Textview - Fatal编程技术网

Android 水平线布局中文本视图中的字体与父高度不匹配?

Android 水平线布局中文本视图中的字体与父高度不匹配?,android,android-layout,android-linearlayout,textview,Android,Android Layout,Android Linearlayout,Textview,我知道已经讨论过很多次,但我找不到解决办法。 我特别在所有颜色上做了标记。这是AlertDialog 为什么要修剪文本本身?我做错了什么 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_

我知道已经讨论过很多次,但我找不到解决办法。 我特别在所有颜色上做了标记。这是AlertDialog

为什么要修剪文本本身?我做错了什么

<?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。也有必要考虑线性布局在AlertDialog。

文本高度+填充将导致TEAXTBOX的高度(MatCHYPrad)。

< P>您的线性布局从其子级获得高度:

android:layout_height="wrap_content"
孩子们从父系中获得身高:

android:layout_height="match_parent"

这是错误。你应该有一个实际指定高度的地方。

我去掉了底部和顶部的所有衬垫和边距。添加了一个小视图



它看起来更好。

只需从文本视图中删除
android:paddingBottom=“30dp”
。此外,您真的不需要2个嵌套的LinearLayout(不利于性能)。单个RelativeLayout更有效。我检查了你的布局。它在我的系统上显示正确。你能发布完整的xml吗?我明白,在我的情况下如何修复?试着在newGrNameLay LinearLayout中设置
android:layout\u height=“100dp”
    <View
    android:layout_width="match_parent"
    android:layout_height="10dp"
    android:layout_margin="3dp"/>