在自定义缩放视图下方的相对布局中放置一个按钮
Place a button in Relative layout below the custom zoomview
我想在自定义缩放视图下方放置一个相对布局。我不希望 Relative Layout 的内容得到 Zoom。我想要一个按钮放置在该相对布局的中心。
这是我的 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="horizontal"
android:background="@drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="@+id/iop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/twentyfive" />
</LinearLayout>
试试这个 -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
android:background="@drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="@+id/iop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/twentyfive" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_centerHorizontal="true"/> //Or use android:layout_centerInParent="true"
</RelativeLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
android:background="@drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="@+id/iop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="@string/twentyfive" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_centerInParent="true"
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
从未测试过代码,但希望它能工作。
我想在自定义缩放视图下方放置一个相对布局。我不希望 Relative Layout 的内容得到 Zoom。我想要一个按钮放置在该相对布局的中心。
这是我的 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="horizontal"
android:background="@drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="@+id/iop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/twentyfive" />
</LinearLayout>
试试这个 -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
android:background="@drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="@+id/iop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/twentyfive" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_centerHorizontal="true"/> //Or use android:layout_centerInParent="true"
</RelativeLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
android:background="@drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="@+id/iop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="@string/twentyfive" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_centerInParent="true"
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
从未测试过代码,但希望它能工作。