This is my layout that is an action bar that I have built:
<LinearLayout
android:orientation="horizontal"
android:id="@+id/Layout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_blue_no_border">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/white"
/>
<TextView
android:id="@+id/textActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:text="@string/app_name"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
Unfortunely the image is on the left and the textview is near the image. I want that the second linear Layout is centered in the first layout. What have I to do?
<RelativeLayout
android:orientation="horizontal"
android:id="@+id/Layout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_blue_no_border">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/white"
/>
<TextView
android:id="@+id/textActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:text="@string/app_name"
android:textStyle="bold"/>
</LinearLayout>
</RelativeLayout>
Or take a look here How to align LinearLayout at the center of its parent?
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加