Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.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 TextView_Android_Layout - Fatal编程技术网

右边有按钮的Android TextView

右边有按钮的Android TextView,android,layout,Android,Layout,嗨,我有一个文本视图,我想在它旁边显示一个按钮。但是layout\u width=“match\u parent”将按钮按出了视图。。。我如何告诉android使用没有按钮的剩余空间 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_

嗨,我有一个文本视图,我想在它旁边显示一个按钮。但是layout\u width=“match\u parent”将按钮按出了视图。。。我如何告诉android使用没有按钮的剩余空间

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <EditText
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:hint="@string/possibility"
        android:inputType="textCapSentences"
        android:singleLine="true" />

    <ImageButton
        android:id="@+id/remove"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:background="@null"
        android:src="@drawable/ic_menu_close_clear_cancel" />

</LinearLayout>

通过定义“匹配父对象”,它采用父对象的布局宽度,并且您已经为父对象定义了“填充父对象”,因此EditText具有“填充父对象”属性


这就是为什么你的按钮不见了。如果您没有在线性布局中为小部件赋予权重,请在编辑文本的
layout\u width
中使用“wrap\u content”(换行内容

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <RelativeLayout
        android:layout_height="wrap_content"
        android:layout_width="fill_parent" >

        <EditText
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/possibility"
            android:inputType="textCapSentences"
            android:singleLine="true" />

        <ImageButton
            android:id="@+id/remove"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/ic_menu_close_clear_cancel"
            android:layout_toRightOf="@id/title" />

    </RelativeLayout>

</LinearLayout>

我必须等到明天
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <RelativeLayout
        android:layout_height="wrap_content"
        android:layout_width="fill_parent" >

        <EditText
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/possibility"
            android:inputType="textCapSentences"
            android:singleLine="true" />

        <ImageButton
            android:id="@+id/remove"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/ic_menu_close_clear_cancel"
            android:layout_toRightOf="@id/title" />

    </RelativeLayout>

</LinearLayout>