I am trying to build this layout
But I am getting this: (The map button in the location would be ideal height and width but the textview doesn't match the height)
My location is a TextView
and my destination is a EditText
I want the TextView
and EditText
to be the same width while the MAP buttons stay "square".
How can I get the textviews height to match and make a square map button?
Here is my layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mycompany.controller.DetailsFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/viewStatus"
android:layout_marginTop="5dp">
<LinearLayout
android:id="@+id/scrollViewDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- LOCATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="LOCATION"
android:textColor="@color/COLOR_BLUE"
android:textSize="24sp"/>
<LinearLayout
android:id="@+id/layoutLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tvLocation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight=".8"
android:background="@color/COLOR_LIGHT_GREY"
android:text="123 MAIN ST., CHATTANOOGA TN 37404"
android:textSize="24sp"/>
<Button
android:id="@+id/btnMapLocation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight=".2"
android:background="@color/COLOR_BLUE"
android:text="MAP"
android:textColor="@color/COLOR_WHITE"/>
</LinearLayout>
<!-- DESTINATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="DESTINATION"
android:textColor="@color/COLOR_BLUE"
android:textSize="24sp"/>
<LinearLayout
android:id="@+id/layoutDestination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/editDestination"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight=".8"
android:ems="10"
android:inputType="textMultiLine"
android:text="407 Broad St., Anywhere ST 00000"/>
<Button
android:id="@+id/btnMapDestination"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight=".2"
android:background="@color/COLOR_BLUE"
android:text="MAP"
android:textColor="@color/COLOR_WHITE"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
I did a slight modification in your code check it!
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp">
<LinearLayout
android:id="@+id/scrollViewDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- LOCATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="LOCATION"
android:textSize="24sp"/>
<LinearLayout
android:id="@+id/layoutLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/searchText"
android:text="Search text here"
android:layout_weight="0.8"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#c8c8c8"
/>
<Button
android:id="@+id/searchButton"
android:text="MAP"
android:layout_weight="0.2"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
/>
</LinearLayout>
<!-- DESTINATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="DESTINATION"
android:textSize="24sp"/>
<LinearLayout
android:id="@+id/layoutLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/searchText"
android:text="Search text"
android:layout_weight="0.8"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<Button
android:id="@+id/searchButton"
android:text="MAP"
android:layout_weight="0.2"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>