我是Android新手,一切都很顺利,直到现在我不得不处理布局。 我想是这样的布局:ImageView:适当缩放按钮
布局应该如何: 图像应适当比例,并保持其比例。
这就是为什么我尝试这个XML代码,但它不按我想要的方式工作。图像保持其比率,但在左侧和右侧超出垂直当屏幕中,并在顶部和底部切割时的水平:
布局如何,它是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:background="@color/background">
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:src="@drawable/logo"
android:gravity="center"
android:scaleType="centerCrop"
android:contentDescription="@string/app_logo"
android:layout_weight="2.5" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center">
<Button
android:id="@+id/id1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="20dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:text="@string/text1"
android:textSize="40sp"
/>
<Button
android:id="@+id/id2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:text="@string/text2"
/>
<Button
android:id="@+id/id3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_gravity="center"
android:text="@string/text3" />
</LinearLayout>
</LinearLayout>
我GOOGLE了很多,但只是找不到我在找什么。 请帮忙!
你能提供的是什么情况,现在的近似图片,应该怎么样子呢? – g00dy 2013-03-05 08:34:37
请分享您的预期输出图片,,以便我们能够弄清楚 – 2013-03-05 08:41:37
我为该问题添加了一张图片。 – JustABit 2013-03-05 08:44:28