• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Align the image and textview at center in Linear Layout.

Thayar

Newbie
I have an Linear Layout with horizontal orientation
Within that I have image on left side and textview on right side .
How to align those image and textview in the center horizontal without using margin?

Here is my code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/menu_colors"
android:gravity="center_horizontal"
>

<ImageView
android:id="@+id/menuimg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/film"
android:layout_gravity="center_horizontal"
/>

<TextView
android:id="@+id/menutext"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="TextView"
android:gravity="center_vertical"
/>

</LinearLayout>
 
Back
Top Bottom