大佬教程收集整理的这篇文章主要介绍了android-RelativeLayout中的layout_centerInParent不在模拟器或设备上居中 ,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<RelativeLayout xmlns:android="http://scheR_135_11845@as.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Fragment"
android:textSize="30sp"
android:layout_centerInParent="true"/>
</RelativeLayout>
很好,但是在模拟器或真实设备上,我看到了:
我想念什么?如何在父母中居中显示该文本?
父布局是FrameLayout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/toolbar"/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/frame_layout">
</FrameLayout>
</LinearLayout>
将您的FrameLayout宽度更改为android:layout_width =“ match_parent”
样本代码
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/toolbar"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/frame_layout">
</FrameLayout>
</LinearLayout>
以上是大佬教程为你收集整理的android-RelativeLayout中的layout_centerInParent不在模拟器或设备上居中 全部内容,希望文章能够帮你解决android-RelativeLayout中的layout_centerInParent不在模拟器或设备上居中 所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。