我正在开发一个安卓应用程序。我希望屏幕上的图像和下面的是image.After的名字下面的图像,即在下半部分应该有一些描述在5-6 lines.Getting的图像在上半部分,但不能在下半部分的文字。
向Mayank致敬
发布于 2015-11-16 20:57:22
如果我是您,我会使用带有weightSum字段的LinearLayout和LinearLayout中每个元素的layout_weight。例如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16p"
android:weightSum=5>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight = 3/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/> </LinearLayout>
在上面的示例中,我们有一个屏幕,它垂直地包含一个ImageView (屏幕的3/5)和两个TextViews (每个屏幕的1/5)。
发布于 2015-11-16 20:57:24
只需要复制这个
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:id="@+id/imageView2"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView2"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView3"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:layout_weight="2" />
</LinearLayout>
发布于 2015-11-16 21:07:03
尝尝这个,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.5"
android:orientation="vertical"
android:weightSum="5" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4"
android:background="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:text="Hello World"
android:paddingBottom="5dp"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.5"
android:orientation="horizontal"
android:background="#336699">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom|center"
android:layout_gravity="bottom|center"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry."
android:textSize="20sp"
android:textColor="@android:color/white" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
输出如下所示:
https://stackoverflow.com/questions/33735802
复制相似问题