【发布时间】:2015-05-16 08:18:45
【问题描述】:
布局是:在视图显示图像的顶部和图像的顶部,在右上角显示位置-永久按钮(同时向下滚动查看图像下方的文本-位置是固定的)。它不起作用:按钮隐藏在图像下方,只有当我向下滚动到文本的白色背景时,我才能看到按钮。这是代码。该按钮是自定义形状:椭圆形,以图像为背景。我还尝试将 android:background="@drawable/btn1_shape" 更改为 android:src="@drawable/btn1_shape" 并且它也不起作用。我说的是 pre 数学主题设计(带有 Z 值等),因为我需要支持向后兼容性...
<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="match_parent"
tools:context="com.example.MainActivity" >
<Button
android:id="@+id/btn1"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="30dp"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:background="@drawable/btn1_shape" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/image1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/picture1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
//Button shape xml: @drawable/btn1_shape
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/primary"/>
</shape>
</item>
<item android:drawable="@drawable/picture2"/>
</layer-list>
【问题讨论】:
标签: android button layout imageview scrollview