gpt4 book ai didi

java - 宽度和高度匹配问题

转载 作者:行者123 更新时间:2023-12-02 03:13:24 26 4
gpt4 key购买 nike

我正在尝试构建这个布局

enter image description here

但是我得到了这个:(该位置的 map 按钮是理想的高度和宽度,但 TextView 与高度不匹配)

enter image description here

我的位置是 TextView,我的目的地是 EditText

我希望 TextViewEditText 具有相同的宽度,而 MAP 按钮保持“方形”。

如何使 TextView 高度匹配并制作方形 map 按钮?

这是我的布局

<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>

最佳答案

我对你的代码做了一点修改,检查一下!

<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>

关于java - 宽度和高度匹配问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40724451/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com