gpt4 book ai didi

android - Android TextView 中的重叠问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:40 25 4
gpt4 key购买 nike

这是一个具有 Google Place API 集成的 fragment 。这是第一张图片: before selecting location

选择一个看起来像这样的地方后:

after selecting location from google places api

这是 XML 文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp">

<in.vaksys.ezyride.utils.PercentLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">

<LinearLayout
android:id="@+id/SearchGetFromLocation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_widthPercent="90%">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FROM"
android:textColor="#ffffff"
android:textSize="12sp" />

<TextView
android:id="@+id/SearchFromMainName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hyderabad"
android:textColor="#FFFFFF"
android:textSize="30sp" />

<TextView
android:id="@+id/SearchFromSubName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Madhapur cyber tower, Hitechcitysad"
android:textColor="#FFFFFF" />

</LinearLayout>

<ImageView
android:id="@+id/SearchGetCurrentLocation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scaleType="fitEnd"
android:src="@drawable/ic_near_me_white_24dp"
app:layout_widthPercent="10%" />


</in.vaksys.ezyride.utils.PercentLinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#CCC" />

<in.vaksys.ezyride.utils.PercentLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">

<LinearLayout
android:id="@+id/SearchGetToLocation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical"
app:layout_widthPercent="90%">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TO"
android:textColor="#FFFFFF"
android:textSize="12sp" />

<TextView
android:id="@+id/SearchToMainName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Seconderabad"
android:textColor="#FFFFFF"
android:textSize="30sp" />

<TextView
android:id="@+id/SearchToSubName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:text="Seconderabad railway stasion, Secondrabad"
android:textColor="#FFFFFF" />

</LinearLayout>

<ImageView
android:id="@+id/Search_btn_swap"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scaleType="fitStart"
android:src="@drawable/swap"
app:layout_widthPercent="10%" />
</in.vaksys.ezyride.utils.PercentLinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#CCC" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:gravity="center"
android:orientation="vertical">

<Button
android:id="@+id/btn_search_ride"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="@drawable/buttonshape"
android:text="@string/search_ride"
android:textColor="#FFFFFF" />

<Button
android:id="@+id/btn_offer_ride"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="@drawable/buttonshape"
android:text="@string/offer_ride"
android:textColor="#FFFFFF" />
</LinearLayout>

</LinearLayout>

这里是 XML 文件,我在这里没有发现任何问题。

Java 文件:

private void ChooseFromLoc() {
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.build();
try {
Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
// .setBoundsBias(new LatLngBounds(new LatLng(), new LatLng()))
.build(getActivity());
startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE_FROM);
} catch (GooglePlayServicesRepairableException e) {
GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), e.getConnectionStatusCode(),
0 /* requestCode */).show();
} catch (GooglePlayServicesNotAvailableException e) {
String message = "Google Play Services is not available: " +
GoogleApiAvailability.getInstance().getErrorString(e.errorCode);
Log.e(TAG, " ajsd : " + message);
Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
}
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE_FROM) {
if (resultCode == Activity.RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(getActivity(), data);
SearchFromMainName.setText(place.getName());
SearchFromSubName.setText(place.getAddress());
LatLng FromLatLng = place.getLatLng();

FromLat = FromLatLng.latitude;
FromLng = FromLatLng.longitude;


} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(getActivity(), data);
Log.e(TAG, "hehh : " + status.getStatusMessage());

} else if (resultCode == Activity.RESULT_CANCELED) {
// TODO: 23-06-2016 The user canceled the operation.
}
}
}

有人能说明为什么会发生这种重叠吗?

最佳答案

正如您所说,您正在使用抽屉导航,然后确保如果您要添加一个 fragment ,那么当您更改选项时,它应该被另一个 fragment 替换。所以请检查一下你没有在一帧中添加多个 fragment 。

关于android - Android TextView 中的重叠问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38242568/

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