0
我有這個觀點在我的Android應用程序的活動:XML的LinearLayout水平,文本顯示不出來
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:orientation="vertical"
android:background="@drawable/bg_card">
<!-- Card Contents go here -->
<TextView
android:id="@+id/breweryTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="20sp"
android:textStyle = "bold"
android:padding="5dip"
>
</TextView>
<ImageView android:id="@+id/breweryImage"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_margin="10dip"/>
</LinearLayout >
</FrameLayout>
<TableLayout
android:id="@+id/tableLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:shrinkColumns="*"
android:stretchColumns="*">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:orientation="vertical"
android:background="@drawable/bg_card">
<!-- Card Contents go here -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/breweryEstablished"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Year Established: "
android:textSize="20sp"
android:textStyle = "bold"
android:padding="5dip"
>
</TextView>
<TextView
android:id="@+id/yearTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text=""
android:textSize="20sp"
android:padding="5dip"
>
</TextView>
</LinearLayout>
</LinearLayout >
</FrameLayout>
</TableLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:orientation="vertical"
android:background="@drawable/bg_card">
<!-- Card Contents go here -->
<TextView
android:id="@+id/beerDescriptionTitle2"
android:textStyle = "bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="20sp"
android:text="Description:"
android:padding="5dip"
></TextView>
<TextView
android:id="@+id/breweryDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="15sp"
android:padding="5dip"
></TextView>
</LinearLayout >
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:orientation="vertical"
android:background="@drawable/bg_card">
<!-- Card Contents go here -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:orientation="horizontal"
>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="All Beers"
android:id="@+id/button"
android:onClick="getAllBeers"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Top Beers"
android:id="@+id/button2"
android:onClick="getTopBeers"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Beers"
android:id="@+id/button2"
android:onClick="getYourTopBeers"
/>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Directions to Brewery"
android:id="@+id/button2"
android:onClick="getDirections"
/>
</LinearLayout >
</FrameLayout>
</LinearLayout>
</ScrollView>
和它產生這樣的效果:
我想什麼發生是在「創建年份」旁邊顯示的年份,這就是爲什麼我的水平線是平躺的。當我把它做成垂直的時候,年份顯示在它的下面,但是當我切換到水平時,年份根本不顯示,如上圖所示。