2016-10-09 4 views
-2

こんにちは、私はいくつかのボタンとwebviewをadmob広告と整列させようとしています。しかし、私が必要とするアライメントは私が得ていない。Androidレイアウトコンポーネントの配置問題

ここは自分のコードです

添付のスクリーンショットは必要なレイアウトです。

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="0dp" 
    android:paddingLeft="0dp" 
    android:paddingRight="0dp" 
    android:paddingTop="0dp" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.profilephotos.dp.MainActivity" 
    tools:showIn="@layout/activity_view_image"> 
    <com.google.android.gms.ads.AdView 
     android:background="@color/adbackcolor" 
     android:id="@+id/adView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/banner_ad_unit_id"> 
    </com.google.android.gms.ads.AdView> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:paddingBottom="@dimen/activity_vertical_margin"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <TableLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_alignParentRight="true"> 

       <TableRow> 
        <WebView 
         android:id="@+id/webViewimage" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:background="#8a0707" 
         android:layout_marginBottom="110dp" 
         android:layout_marginTop="0dp" 
         android:layout_marginLeft="0dp" 
         android:layout_marginRight="0dp" 
         /> 
       </TableRow> 
       <TableRow android:layout_height="match_parent"> 

        <Button 
         android:id="@+id/btnsaveimage" 
         android:layout_width="wrap_content" 
         android:layout_height="56dp" 
         android:layout_marginBottom ="5dp" 
         android:layout_weight="1" 
         android:text="Save" 
         android:onClick="triggeractionbtnclick" 
         android:layout_above="@+id/adView" /> 

        <Button 
         android:id="@+id/btnshareimage" 
         android:layout_width="wrap_content" 
         android:layout_height="56dp" 
         android:layout_marginBottom ="5dp" 
         android:layout_weight="1" 
         android:text="Share" 
         android:onClick="triggeractionbtnclick" 
         android:layout_above="@+id/adView" /> 

        <Button 
         android:id="@+id/btnsetas" 
         android:layout_width="wrap_content" 
         android:layout_height="56dp" 
         android:layout_marginBottom ="5dp" 
         android:layout_weight="1" 
         android:text="Set As" 
         android:onClick="triggeractionbtnclick" 
         android:layout_above="@+id/adView"/> 

       </TableRow> 

      </TableLayout> 

     </LinearLayout> 

    </LinearLayout> 


</RelativeLayout> 

私は間違っていますか? layout sample

答えて

1

ソリューション:それは魔法のように動作

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     xmlns:ads="http://schemas.android.com/apk/res-auto"> 

    <android.support.v7.widget.Toolbar 
     android:layout_width="match_parent" 
     android:id="@+id/toolbar" 
     android:background="@color/colorPrimary" 
     android:layout_height="wrap_content"> 

    </android.support.v7.widget.Toolbar> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     android:layout_alignParentBottom="true" 
     ads:adUnitId="@string/banner_home_footer"> 
    </com.google.android.gms.ads.AdView> 


    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_above="@+id/adView" 
     android:id="@+id/table" 
     android:layout_height="wrap_content"> 

     <TableRow 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" > 

      <Button android:layout_width="wrap_content" 
       android:layout_weight="1" 
       android:text="Button 1" 
       android:layout_height="wrap_content"/> 

      <Button android:layout_width="wrap_content" 
       android:layout_weight="1" 
       android:text="Button 2" 
       android:layout_height="wrap_content"/> 

      <Button android:layout_width="wrap_content" 
       android:layout_weight="1" 
       android:text="Button 3" 
       android:layout_height="wrap_content"/> 
     </TableRow> 

    </TableLayout> 


    <WebView 
     android:layout_width="match_parent" 
     android:layout_below="@+id/toolbar" 
     android:id="@+id/webview" 
     android:layout_above="@+id/table" 
     android:layout_height="match_parent"/> 

</RelativeLayout> 
+0

ありがとう! – user3391693

+0

解決策だけを追加しないでください。これがなぜ来たのか、関連する参照を追加してください。 –

0

私はあなたの意見を概説するようにこれを達成できます。

<RelativeLayout 

    <WebView 
     height="match_parent" 
     widht="match_parent" 
     id="webview1"/> 

    <LinearLayout 
    layout_above="@id/webview1" 
    align_parent_bottom="true" 
    orientation="vertical" 

     <LinearLayout weight_sum=3 
      orientation="horizontal"> 

       <Buttion width=0" 
        weight=1 /> 

       <Buttion width=0" 
        weight=1 /> 

       <Buttion width=0" 
        weight=1 /> 

     </LinearLayout> 

     <AdMobView /> 

    </LinearLayout> 

</RelativeLayout> 

あなたの問題は解決しますが、