0

I am creating an intro activity and What I want is that logo was double bigger than text, and the text was centered to the layout.

With the next code I am having problems with diferents layouts (in some screens the TextView is not shown:

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

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <ImageView
            android:id="@+id/image_intro"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/image_view_desc"
            android:scaleType="fitCenter"
            android:src="@drawable/iconok" />
    </LinearLayout> 

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/email_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:textSize="55sp"
            android:text="@string/loading_text3" />
    </LinearLayout>

</LinearLayout>

What I am doing wrong?

4

5 に答える 5

1

質問とコメントによると、以下のスニペットが役立つと思います。

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

    <ImageView
        android:id="@+id/image_intro"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="66"
        android:scaleType="fitCenter"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/email_textview"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:gravity="left|center"
        android:layout_weight="33"
        android:text="@string/app_name"
        android:textSize="55sp" />

</LinearLayout>
于 2013-10-26T07:42:12.370 に答える
1
// try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:weightSum="3"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:gravity="center"
        android:layout_weight="2" >

        <ImageView
            android:id="@+id/image_intro"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:contentDescription="@stringimage_view_desc"
            android:scaleType="fitXY"
            android:adjustViewBounds="true"
            android:src="@drawable/image_view_desc" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/email_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="55sp"
            android:text="@stringloading_text3" />
    </LinearLayout>

</LinearLayout>
于 2013-10-26T05:31:49.663 に答える
1

これを試してmargin、要件に応じて変更してください。

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical"
android:weightSum="3" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="2" >

    <ImageView
        android:id="@+id/image_intro"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:contentDescription=""
        android:src="@drawable/ic_launcher" />
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="center_horizontal" >

    <TextView
        android:id="@+id/email_textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="abcd"
        android:textSize="55sp" />
</LinearLayout>

于 2013-10-26T06:04:04.757 に答える