屏幕截图中的Title
是异步更新的,可以是2-3行。这意味着它应该推动虚拟文本。但是我在右边有一个占位符,可以使图像变得更复杂。
我希望根据图片或左上角的文字推送虚拟冗长文本。什么是好结构?
目前在我的代码中,如果我异步更新标题,则会推送name
,address
和12:00
,而不是大文本。如果它们溢出,这4个textview隐藏在大文本视图之下。
我知道它很乱,但布局是:
-RelativeLayout
-Scrollview
-Linearlayout (vertical)
-Linearlayout
-Linearlayout(vertical)
-The 4 textviews
-Image
-Textview with big dummy text
这是我的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:animateLayoutChanges="true"
tools:context=".EventDisplay" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/linearLayout1"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.74" >
<LinearLayout
android:layout_width="178dp"
android:layout_height="match_parent"
android:layout_weight="7.03"
android:orientation="vertical" >
<TextView
android:id="@+id/eventTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="20dp" />
<TextView
android:id="@+id/venueName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:textSize="12dp" />
<TextView
android:id="@+id/eventAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="address"
android:textSize="12dp" />
<TextView
android:id="@+id/eventStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollHorizontally="true"
android:text="12:00"
android:textSize="12dp" />
</LinearLayout>
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@color/darkGrey"
android:maxHeight="100dp"
android:maxWidth="100dp" />
</LinearLayout>
<TextView
android:id="@+id/eventDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="8.55"
android:text="When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show().When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show().When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show().When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show().When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show().When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show().When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show().When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show().When the action bar hides, the system adjusts your layout to fill the screen space now available. You can bring the action bar back by calling show()." />
</LinearLayout>
</ScrollView>
</RelativeLayout>
我的另一个想法是在LinearLayout(包装4个textviews)上放置一个等于图像大小(例如100dp)的边距。然而,即使我在图像上有负余量(-100dp)将其带回左侧,它也不会。
Ps:不幸的是,以固定宽度包装标题的线性布局是无用的,因为我们必须关心许多设备。
答案 0 :(得分:0)
试试这个..
我只发布了特定的LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.74" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7"
android:orientation="vertical" >
<TextView
android:id="@+id/eventTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="20dp" />
<TextView
android:id="@+id/venueName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:textSize="12dp" />
<TextView
android:id="@+id/eventAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="address"
android:textSize="12dp" />
<TextView
android:id="@+id/eventStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollHorizontally="true"
android:text="12:00"
android:textSize="12dp" />
</LinearLayout>
<ImageView
android:id="@+id/imageView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@color/darkGrey"/>
</LinearLayout>
或者使用LinearLayout
使用RelativeLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.74" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/imageView1"
android:orientation="vertical" >
<TextView
android:id="@+id/eventTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="20dp" />
<TextView
android:id="@+id/venueName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:textSize="12dp" />
<TextView
android:id="@+id/eventAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="address"
android:textSize="12dp" />
<TextView
android:id="@+id/eventStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollHorizontally="true"
android:text="12:00"
android:textSize="12dp" />
</LinearLayout>
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:background="@color/darkGrey" />
</RelativeLayout>