问:我在相对布局中的android studio应用程序中创建了六个按钮。这些按钮在android studio的预览模式下显示为“确定”,但是当我安装应用程序以在手机或仿真器上进行测试时,按钮的倒数第二个不显示。可能是什么问题
这是我的代码
<?xml版本= “ 1.0”编码= “ 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 = “ wrap_content”
android:paddingBottom = “ @ dimen / activity_vertical_margin”
android:paddingLeft = “ @ dimen / activity_horizontal_margin”
android:paddingRight = “ @ dimen / activity_horizontal_margin”
android:paddingTop = “ @ dimen / activity_vertical_margin”
工具:上下文= “ com.example.nelson.kuzaapp.MainActivity” >
<ImageView
android:layout_width = “ match_parent”
android:layout_height = “ match_parent”
android:src = “ @ drawable / logoo”
android:contentDescription = “ @ string / logo”
android:id = “ @ + id / logo”
android:layout_marginTop = “” -500dp“
/>
<!-制作查询按钮->
<按钮
style = “?android:textAppearanceSmall”
android:layout_width = “ match_parent”
android:layout_height = “ wrap_content”
android:layout_marginTop = “ 150dp”
android:text = “ @ string / make_farming_query”
android:id = “ @ + id / buttonAskExpert”
android:layout_below = “ @ + id / logo”
android:layout_alignParentTop = “ true”
android:layout_alignParentRight = “ true”
android:layout_alignParentEnd = “ true”
/>
<!-查看产品按钮->
<按钮
style = “?android:textAppearanceSmall”
android:layout_width = “ match_parent”
android:layout_height = “ wrap_content”
android:layout_marginTop = “ 16dp”
android:text = “ @ string / view_products”
android:id = “ @ + id / buttonViewProducts”
android:layout_below = “ @ + id / buttonAskExpert”
android:layout_alignLeft = “ @ + id / buttonAskExpert”
android:layout_alignStart = “ @ + id / buttonAskExpert”
/>
<!-农民登录按钮->
<按钮
style = “?android:textAppearanceSmall”
android:layout_width = “ match_parent”
android:layout_height = “ wrap_content”
android:layout_marginTop = “ 16dp”
android:text = “ @ string / farmer_login”
android:id = “ @ + id / buttonFarmerLogin”
android:layout_below = “ @ + id / buttonViewProducts”
android:layout_alignLeft = “ @ + id / buttonViewProducts”
android:layout_alignStart = “ @ + id / buttonViewProducts” />
<!-农民注册->
<按钮
style = “?android:textAppearanceSmall”
android:layout_width = “ match_parent”
android:layout_height = “ wrap_content”
android:layout_marginTop = “ 16dp”
android:text = “ @ string / farmer_registration”
android:id = “ @ + id / buttonRegisterFarmer”
android:layout_below = “ @ + id / buttonFarmerLogin”
android:layout_alignLeft = “ @ + id / buttonFarmerLogin”
android:layout_alignStart = “ @ + id / buttonFarmerLogin” />
<!-Twitter按钮->
<按钮
style = “?android:textAppearanceSmall”
android:layout_width = “ match_parent”
android:layout_height = “ wrap_content”
android:layout_marginTop = “ 16dp”
android:text = “ @ string / follow_us_on_twitter”
android:id = “ @ + id / buttonFollowTwitter”
android:layout_below = “ @ + id / buttonRegisterFarmer”
android:layout_alignLeft = “ @ + id / buttonRegisterFarmer”
android:layout_alignStart = “ @ + id / buttonRegisterFarmer” />
<!-Facebook按钮->
<按钮
style = “?android:textAppearanceSmall”
android:layout_width = “ match_parent”
android:layout_height = “ wrap_content”
android:layout_marginTop = “ 16dp”
android:text = “ @ string / like_us_on_facebook”
android:id = “ @ + id / buttonLikeFacebook”
android:layout_below = “ @ + id / buttonFollowTwitter”
android:layout_alignLeft = “ @ + id / buttonFollowTwitter”
android:layout_alignStart = “ @ + id / buttonFollowTwitter” />
</ RelativeLayout>、
答:您是否在活动或片段中附加了相同的布局。请也分享您的活动/片段的代码。
如果要附加相同的布局,则可以尝试以下几点:-
从imageview中删除layout_marginTop =“-500dp”
使用wrap_content而不是将match_parent赋予imageview的宽度和高度