【发布时间】:2016-06-06 22:33:05
【问题描述】:
目前我的代码在屏幕底部放置了一个按钮:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|bottom">
<ImageButton
android:id="@+id/button1"
android:layout_width="95dp"
android:layout_height="95dp"
android:layout_centerInParent="true"
android:gravity="center"
android:src="@drawable/main_button"
/>
</LinearLayout>
</RelativeLayout>
但是,我希望将其稍微对齐到屏幕底部下方,因此按钮的一小部分会被剪掉(比如 20%)。最终,我的最终结果是,当我点击并向上拖动按钮时,它会向上移动并显示整个按钮,但在此之前,它的底部被剪掉了。
关于如何将按钮对齐到屏幕底部有很多问题,但我似乎找不到任何将其对齐到屏幕底部下方的问题。
有什么方法可以这样做,还是我没有使用正确的搜索词?
编辑:从答案中,我尝试了 android:translationY="20dp" 但它没有用,但我尝试了 android:layout_marginBottom="-20dp" 并且它对我有用。
【问题讨论】:
-
如果你可以将其与底部对齐,那么你可以添加一个上边距以将其推离屏幕
标签: android android-layout button android-button