Android中使用布局的按钮定位
几个小时后,我无法修复活动底部的按钮。要么不可见,要么在顶部。我也尝试过没有相对布局,我尝试过添加另一个线性布局,但我仍然不知道如何设置这个按钮Android中使用布局的按钮定位,android,android-layout,Android,Android Layout,几个小时后,我无法修复活动底部的按钮。要么不可见,要么在顶部。我也尝试过没有相对布局,我尝试过添加另一个线性布局,但我仍然不知道如何设置这个按钮 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".News" >
<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="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/news" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/newsbutton"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Chiudi" />
</LinearLayout>
</RelativeLayout>
只需在按钮中添加android:layout_=“@id/webView1” 如果要使用LinearLayout,则可以将填充空白的小部件设置为:layout_height=“0dp”和layout_weight=“1”。这也应该可以完成任务。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/news" />
<WebView
android:id="@+id/webView1"
android:layout_below="@id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/newsbutton"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:text="Chiudi" />
</RelativeLayout>
首先,旧版Android布局编辑器中有一条警告,RelativeLayout或LinearLayout都是无用的。这应该是给你的提示。注意警告,它们在大多数情况下都很有用
实际上,您可以摆脱线性布局
因此,解决方案是:
android:layout_down=“@+id/imageView1”
添加到网络视图。android:layout\u alignParentBottom=“true”
添加到按钮。<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="TODO: DESCRIPTION"
android:src="@drawable/ic_launcher" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView1" />
<Button
android:id="@+id/newsbutton"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:text="Chiudi" />
</RelativeLayout>
在按钮组件中复制粘贴以下内容;)
只玩数字游戏,我肯定你会找到窍门:)你能发布一个屏幕截图吗?您的按钮可能被从屏幕底部按下。使用您的标签,我看不到按钮。同样的问题。谢谢。ImageView将与WebView重叠。请在下面添加>>android:layout_=“@id/imageView1”回答得好!帮我大忙!谢谢安卓2.1应用程序崩溃
android:layout_marginBottom="147dp"
android:layout_marginTop="50dp"
android:layout_marginleft="50dp"
android:layout_marginRight="47dp"