tes*_*der 4 layout android android-button android-view
I would like to align button on center and make offset i was tried approach like that Is there a way to offset a view from center in Android? but it do not work. For example:
<View
android:id="@+id/fakeView"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerInParent="true"
android:paddingTop="80dp"
android:background="#FFAABB" />
Run Code Online (Sandbox Code Playgroud)
Still stay on center
Is any way accomplish like this:
UPDATE:
my full layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageButton
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_marginLeft="100dp"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
use*_*306 11
一种方法是使用一个位于相对布局中心的ancher视图,设置你的按钮并设置你的边距.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<View
android:id="@+id/anchor"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true" />
<ImageButton
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginRight="50dp"
android:layout_toRightOf="@+id/anchor"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
或尝试:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<ImageButton
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginRight="50dp"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7203 次 |
最近记录: |