Sud*_*dar 1 layout android relativelayout android-linearlayout
我在layout.xml中有以下代码.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent">
<EditText android:hint="@string/feed_url"
android:id="@+id/feedUrl" android:textSize="14dp" android:inputType="textUri"
android:layout_marginRight="45dp" android:layout_height="wrap_content" android:layout_width="fill_parent">
</EditText>
<Button android:id="@+id/getGraph"
android:text="@string/get"
android:layout_toRightOf="@id/feedUrl"
android:layout_alignParentRight="true"
android:layout_height="wrap_content" android:width="45dp" android:layout_width="wrap_content">
</Button>
</RelativeLayout>
<WebView android:id="@+id/wv1" android:layout_height="wrap_content"
android:layout_width="fill_parent" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在eclipse插件布局创建器中,EditText和按钮正确显示.(见下面的截图)

但是在设备和模拟器上,按钮不会被隐藏.(见下面的截图)

知道为什么按钮隐藏在设备中?
请尝试对您的代码进行以下更改.您必须首先定义按钮,因为它具有固定宽度,然后放置EditText以填充位于按钮左侧的剩余空间.该按钮也必须首先定义(在Android 2.2之前,即).
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button
android:id="@+id/getGraph"
android:text="@string/get"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<EditText
android:hint="@string/feed_url"
android:id="@+id/feedUrl"
android:textSize="14dp"
android:inputType="textUri"
android:layout_marginRight="45dp"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_toLeftOf="@id/getGraph"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25147 次 |
| 最近记录: |