我有一个带有两个按钮的取景器,取景器的左侧和右侧。
有文字被投影在取景器上。当我运行模拟器时,viewFlipper 上的文本会将两个按钮推出屏幕并占用整个空间。
如何确保 viewFlipper 上的文本布局不会推出按钮并粘在 viewFlipper 的布局内?
这是viewflipper的xml布局
<Button
android:id="@+id/button_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/promoflipper"
android:background="@drawable/button_left"
android:layout_below="@+id/titel1"
android:layout_alignParentLeft="true"
/>
<Button
android:id="@+id/button_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/promoflipper"
android:background="@drawable/button_right"
android:layout_below="@+id/titel1"
android:layout_alignParentRight="true"
/>
<ViewFlipper
android:id="@+id/promoflipper"
style="@style/MainTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/titel1"
android:layout_centerInParent="true"
android:background="@drawable/mat"
>
</ViewFlipper>
这是viewflipper上文本的xml布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/promo_flipper"
>
<TextView
android:id="@+id/promoTitel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:text="@string/promoTitel"
android:textColor="@color/listSelectorFocused2"
android:textSize="16dip"
/>
<TextView
android:id="@+id/promoText"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/listSelectorPressed3"
android:gravity="center"
android:padding="10dip" />
<com.phi.android.ui.widget.AutoResizeTextView
android:id="@+id/promoLine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dip"
android:textColor="@color/listSelectorFocused2"
android:textSize="16sp" />
这是代码:
LinearLayout flipLayout = (LinearLayout) inflater.inflate(
R.layout.promo_flipper,
promoFlipper, false);
TextView promoTitel = (TextView) flipLayout
.findViewById(R.id.promoTitel);
TextView promoText = (TextView) flipLayout
.findViewById(R.id.promoText);
// Make a textholder
String text = "";
// Get the list with this Place's Promo's
List<Promo> promos = promoList.get(i);
// Run through the promo's and add them to the textholder
for (Promo promo : promos) {
text += promo.getDescription() + "\n";
}
// Set the title and promo text
promoTitel.setText(getResources()
.getString(R.string.promoTitel)
+ " "
+ placeList.get(i).getName());
promoText.setText(text);
// Add the inflated view to the flipper
promoFlipper.addView(flipLayout);