最后将嵌套的线性布局按钮文本裁剪掉

时间:2014-02-17 05:59:49

标签: android android-linearlayout

Android Studio 0.4.5

您好,

我已从Activity中创建了一个对话框。哪个显示如下: enter image description here

取消缺少'l',删除缺少'e'。 我试图调整文本大小,但这不起作用。我一直在玩它。但似乎无法找到解决方案。

这是我的xml布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/ivRabbitLogo"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:scaleType="center"
        android:background="#ff20a3ff"
        android:contentDescription="Logo of Application" />

    <EditText
        android:id="@+id/etUpdateDlgName"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:inputType="text"
        android:hint="Name"
        android:textSize="22sp" />

    <EditText
        android:id="@+id/etUpdateDlgPhone"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:inputType="phone"
        android:hint="Phone"
        android:textSize="22sp" />

    <EditText
        android:id="@+id/etUpdateDlgEmail"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:inputType="textEmailAddress"
        android:hint="Email"
        android:textSize="22sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="horizontal"
        android:layout_weight="1">

        <Button
            android:id="@+id/btnCancel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Cancel"
            android:textSize="20sp"
            android:layout_weight="1" />

        <Button
            android:id="@+id/btnSave"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Save"
            android:textSize="20sp"
            android:layout_weight="1" />

        <Button
            android:id="@+id/btnDelete"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Delete"
            android:textSize="20sp"
            android:layout_weight="1" />

    </LinearLayout>

</LinearLayout>

非常感谢任何建议,

5 个答案:

答案 0 :(得分:1)

按照以下更改声明您的按钮,

只需添加一个带有按钮的重量标签,如下所示

<Button
            android:id="@+id/btnCancel"
            android:layout_width="0dp"                         // Change here
            android:layout_height="wrap_content"
            android:text="Cancel"
            android:textSize="20sp"
            android:layout_weight="1" />

        <Button
            android:id="@+id/btnSave"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="Save"
            android:textSize="20sp"
            android:layout_weight="1" />

        <Button
            android:id="@+id/btnDelete"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="Delete"
            android:textSize="20sp"
            android:layout_weight="1" />

答案 1 :(得分:1)

看看这个

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<ImageView
    android:id="@+id/ivRabbitLogo"
    android:layout_width="match_parent"
    android:layout_height="64dp"
    android:background="#ff20a3ff"
    android:contentDescription="Logo of Application"
    android:scaleType="center" />

<EditText
    android:id="@+id/etUpdateDlgName"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hint="Name"
    android:inputType="text"
    android:textSize="22sp" />

<EditText
    android:id="@+id/etUpdateDlgPhone"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hint="Phone"
    android:inputType="phone"
    android:textSize="22sp" />

<EditText
    android:id="@+id/etUpdateDlgEmail"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hint="Email"
    android:inputType="textEmailAddress"
    android:textSize="22sp" />

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

    <Button
        android:id="@+id/btnCancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Cancel"
        android:textSize="20sp" />

    <Button
        android:id="@+id/btnSave"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Save"
        android:textSize="20sp" />

    <Button
        android:id="@+id/btnDelete"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Delete"
        android:textSize="20sp" />
</LinearLayout>

答案 2 :(得分:1)

在你的代码中尝试这个...希望这会有用..

<LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:orientation="horizontal"
        android:layout_weight="1">
        <Button
            android:id="@+id/btnCancel"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="Cancel"
            android:textSize="20sp"
            android:layout_weight="1" />

        <Button
            android:id="@+id/btnSave"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="Save"
            android:textSize="20sp"
            android:layout_weight="1" />

        <Button
            android:id="@+id/btnDelete"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="Delete"
            android:textSize="20sp"
            android:layout_weight="1" />

    </LinearLayout>

答案 3 :(得分:1)

你不应该在BUtton(孩子)中使用android:layout_weight="1",而是使用android:weight="1"

答案 4 :(得分:1)

使用此...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<ImageView
    android:id="@+id/ivRabbitLogo"
    android:layout_width="match_parent"
    android:layout_height="64dp"
    android:background="#ff20a3ff"
    android:contentDescription="Logo of Application"
    android:scaleType="center" />

<EditText
    android:id="@+id/etUpdateDlgName"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hint="Name"
    android:inputType="text"
    android:textSize="22sp" />

<EditText
    android:id="@+id/etUpdateDlgPhone"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hint="Phone"
    android:inputType="phone"
    android:textSize="22sp" />

<EditText
    android:id="@+id/etUpdateDlgEmail"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hint="Email"
    android:inputType="textEmailAddress"
    android:textSize="22sp" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/btnCancel"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Cancel"
        android:textSize="20sp" />

    <Button
        android:id="@+id/btnSave"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Save"
        android:textSize="20sp" />

    <Button
        android:id="@+id/btnDelete"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Delete"
        android:textSize="20sp" />
</LinearLayout>

</LinearLayout>