我试图缩放ImageButton
以适应屏幕宽度的50%并将其居中放置,无论原始图像或设备屏幕大小如何。 This image更准确地描述了我正在寻找的最终结果。ImageButton相对大小和位置
任何帮助将是非常赞赏。谢谢。实现你正在寻找的效果
我试图缩放ImageButton
以适应屏幕宽度的50%并将其居中放置,无论原始图像或设备屏幕大小如何。 This image更准确地描述了我正在寻找的最终结果。ImageButton相对大小和位置
任何帮助将是非常赞赏。谢谢。实现你正在寻找的效果
的一种方法是使用LinearLayout
2隐形Views
相结合的儿童将作为两边25%填充的weight
属性。不过,严重的是,你的问题可能会更好,下次请阅读SO发布指南。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="20dp">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:visibility="invisible"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:layout_weight="0.5"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:visibility="invisible"/>
</LinearLayout>
对不起,这个问题是如何提出的,但是很晚,我认为一张图片胜过千言万语。非常感谢,这几乎是在做。有两件事:ImageButtons不能正确缩放图像,所以我使用了ImageViews,为了去除缩放后留下的空间,我必须添加'android:adjustViewBounds =“true”''。 – alexdemartos
这将有助于看到一些你的努力/企图在此实现。 – Joel