2010-11-25 12 views
0

admob私のappの上部に広告を挿入しようとしていますが、通常のテキストは中央に中央に配置する必要があります。コンポーネントが表示されます。..android xml layout_gravity = "center"の上にコンポーネントを配置

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:myapp="http://schemas.android.com/apk/res/test.testpkg" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="center" 
    android:gravity="center" 
    android:background="@drawable/background" 
    android:padding = "10dip" > 

    <com.admob.android.ads.AdView 
     android:id="@+id/ad" 
     android:gravity="center" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     myapp:backgroundColor="#000000" 
     myapp:primaryTextColor="#FFFFFF" 
     myapp:secondaryTextColor="#CCCCCC" /> 

    <test.testpkg.CustomTextView android:id="@+id/landscapeText" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor = "#000" 
     android:textSize="40sp" 
     android:shadowColor="#FFF" 
     android:shadowDx="1.2" 
     android:shadowDy="1.2" 
     android:shadowRadius="1.2" 
     android:gravity="center_vertical" 
     android:text ="Test" /> 
</LinearLayout> 

答えて

1

のLinearLayoutは、追加の属性アンドロイドあり:オリエンテーション(doc). デフォルト値イスト「水平」を、現時点ではCustomTextViewがAdViewの権利をレンダリングされるので、あなたは、「垂直」必要があります画面外に表示されます。

追加ヒント:CustomTextViewを実際に画面の真ん中に配置したい場合は、LinearLayoutの代わりにRelativeLayoutを使用し、属性値を追加する必要があります。android:layout_centerInParent = "true" - >が中央に表示されます。

関連する問題