tur*_*boy 36 android view android-linearlayout
我有以下布局我想让textview出现在视图的中心和中间.我怎么能做到这一点?
我在图形视图中查看布局时尝试调整各种重力属性,但似乎没有任何改变它.我想在中心的textview我已经完成但是在视图的中间.
谢谢亚光.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/carefreebgscaledalphajpg" >
<TextView
android:id="@+id/textviewdatefornocallspage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="You have no calls for "
android:textSize="25sp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Hou*_*ine 61
将gravity设置为linearLayout标记的中心:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/carefreebgscaledalphajpg" >
Run Code Online (Sandbox Code Playgroud)
或使用RelativeLayout这样的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/carefreebgscaledalphajpg" >
<TextView
android:id="@+id/textviewdatefornocallspage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="You have no calls for "
android:textSize="25sp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
很简单,我试过很多回答,但所有的答案都不起作用......最后这种方法对我有用
<LinearLayout
android:layout_below="@+id/iv_divider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="@dimen/_10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mycredits"
android:textColor="@color/colorGray"
android:gravity="center"
android:textSize="@dimen/_25dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
43445 次 |
| 最近记录: |