Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.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
Java 元素从屏幕中消失_Java_Android - Fatal编程技术网

Java 元素从屏幕中消失

Java 元素从屏幕中消失,java,android,Java,Android,我有以下代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" and

我有以下代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView
            android:layout_marginLeft="5dip"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/text"
            android:text="@string/errore"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"></TextView>

    <ImageButton
        android:id="@+id/share_btn"
        android:layout_width="55dp"
        android:layout_height="55dp"
        android:contentDescription="@string/share"
        android:src="@drawable/ic_action_share_green" />

</LinearLayout>

我应该将
图像按钮
放在
文本视图
的右侧,但是如果我将
方向
更改为
水平
,按钮有时(取决于
文本视图
中的文本)不可见。 我该怎么修理

多谢各位。
PS:很抱歉出现任何错误,我是意大利人
:(

将您的textView设置为固定宽度,而不是包装内容。在textView和imageview之间插入一个空白视图,以便imageview保持在右侧

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="3"
    android:orientation="horizontal" >
    <TextView
            android:layout_marginLeft="5dip"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/text"
            android:text="@string/errore"
            android:layout_width="0dp"
            android:layout_weight="2"
            android:layout_height="wrap_content"></TextView>

    <ImageButton
        android:id="@+id/share_btn"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="55dp"
        android:contentDescription="@string/share"
        android:src="@drawable/ic_action_share_green" />

</LinearLayout>


谢谢,但这并不是针对所有屏幕尺寸优化的检查我的编辑,这将为总宽度的textview和imageview分配2/3的空间。没有“更数学化”的方法?也可以利用表格…谢谢:)