如何使用文本视图对齐Imageview和描述,如图所示

时间:2016-06-14 07:27:47

标签: java android-layout

你能否帮我一个ImageView以及'描述'有标题1和文字,标题2和一些文字。

我试图这样做,但我无法完全按照图片中所示完成:

my_picture

如果描述更多,则需要有滚动条。它适用于所有屏幕尺寸。这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ScrollView
        android:id="@+id/sv_inner"
        android:layout_width="fill_parent" android:layout_height="fill_parent">

        <LinearLayout
            android:id="@+id/rl_inner_layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="fitXY"
                android:layout_gravity="center"
                android:src="@drawable/image1" />

            <TextView
        android:id="@+id/UpdateTimeText"
        android:text="is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center"
        android:layout_marginTop="4dp"
        android:layout_marginRight="4dp" />



        </LinearLayout>
    </ScrollView>

</LinearLayout>


flag

我尝试使用按钮添加自定义标题栏,但这会破坏我的用户界面。所以我想在我的UI本身放置一个页脚,它位于滚动条之外 有2个按钮后面和下一个。

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginLeft="50dp"
    android:layout_marginRight="50dp"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/imageView"
        android:layout_alignParentTop="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:scaleType="fitXY"
        android:src="@drawable/directory_icon" />

    <ScrollView
        android:id="@+id/sv_inner"
        android:layout_below="@+id/imageView"
        android:layout_above="@+id/linearLayoutButtons"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical">

            <TextView

                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="4dp"
                android:layout_marginTop="4dp"
                android:text="HeadLine 1"
                android:textColor="@android:color/holo_red_light" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="4dp"
                android:layout_marginTop="4dp"
                android:text="is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." />

            <TextView

                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="4dp"
                android:layout_marginTop="4dp"
                android:text="HeadLine 2"
                android:textColor="@android:color/holo_red_light" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="4dp"
                android:layout_marginTop="4dp"
                android:text="is simply dummy text of the printing and typesetting industry." />
        </LinearLayout>


    </ScrollView>

    <LinearLayout
        android:id="@+id/linearLayoutButtons"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:text="previous"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="next"/>
    </LinearLayout>

</RelativeLayout>