[英]How can i make a Button in android appear in a fixed position and always in front of all other views?
I know the code might not be well formatted but I want the button (last tag) to always appear in front of all other views if the description is long the button disappears.我知道代码可能格式不正确,但我希望按钮(最后一个标签)总是出现在所有其他视图的前面,如果描述很长,按钮就会消失。 I'm using scrollView and if any long text appears but this makes the button go down the screen.我正在使用 scrollView 并且如果出现任何长文本,但这会使按钮 go 在屏幕下方。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="vertical">
<Button
android:layout_gravity="bottom|end"
android:id="@+id/cart_button"
android:layout_width="250dp"
android:layout_height="55dp"
android:layout_marginBottom="10dp"
android:iconTint="@color/black"
android:elevation="6dp"
android:text="ADD TO CART"
android:textAppearance="?attr/textAppearanceButton"
android:textColor="#28022E"
android:textSize="20sp"
app:backgroundTint="#F6F2FA"
app:elevation="10dp"
app:rippleColor="#FFF"
app:shapeAppearance="?attr/shapeAppearanceSmallComponent"
app:strokeColor="#0000"
app:strokeWidth="10dp" />
</RelativeLayout>
Take your button out of scrollview.将您的按钮从滚动视图中取出。 something like:就像是:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
// content that you wants to scroll
</ScrollView>
<Button alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.