I have to build layout like at the picture below.
The main task is to center the text.
""https://i.sstatic.net/gmuyX.jpg" alt="此处输入图像描述"/ >
我使用此 xml 来执行布局 。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:orientation="vertical" >
<LinearLayout
android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@+id/author"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/author">
</LinearLayout>
<LinearLayout
android:id="@+id/footer_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<LinearLayout
android:id="@+id/menu_layout"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="@drawable/nav_overlay"
android:gravity="center_horizontal"
android:orientation="horizontal">
<Button
android:id="@+id/previous"
android:layout_width="45dp"
android:layout_height="45dp"
android:background="@drawable/button" />
</LinearLayout>
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/admob_id"
ads:loadAdOnCreate="true" />
</LinearLayout>
</RelativeLayout>
But it works incorrectly.
I need to center TextView
android:id="@+id/author"
inside LinearLayout
android:id="@+id/ll"
. But it is centered in the parent RelativeLayout
android:id="@+id/main_layout"
.
I use android:layout_height="fill_parent"
for LinearLayout
android:id="@+id/ll"
.
How can my Layout fill not the parent but only remaining space?
Give an example of its implementation, if anyone come to similar issue.
EDIT: Now I have wrong centered text like at the picture below now.
At this moment, I think the best solution is to use android:layout_weight.
But when the ads are not shown - the proportions are violated.