Android UI 优化 [ 类别:Layout ] #1

本文对比了LinearLayout与RelativeLayout在资源消耗上的区别,特别是在大量Item显示时。通过具体案例展示了如何使用RelativeLayout进行优化,减少层级并提高效率。

有一句古话:不论黑猫白猫,能抓到耗子就是好猫。这个也许在某些方面是有道理的,但对于我们追求精益求精的思想是背道而驰的,往往就是因为满足于一个结果,而放弃探求更加优化的处理方法。

当关注应用程序或者游戏所达到的结果时,往往非常容易忽视一些优化的问题,例如内存优化,线程优化,Media优化和UI优化等等。不同的模块都存在更为巧妙的方式来对待一般性问题,所以每当我们实现一个行为后,稍微多花一些时间来考虑目前所作的工作是否存在更为高效的解决办法。

这一次我们对常用的UI Layout优化说起,这个例子转载于 android developing blog

在Android中最常用LinearLayout表示UI的框架,而且也是最直观和方便的方法。例如创建一个UI用于展现Item的基本内容。如图所示:

ui_layout_01

线框图:

ui_layout_02

直接可以通过LinearLayout快速的实现这个UI的排列:

?[Copy to clipboard] View Code XML
<LinearLayout xmlns:
    android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"

    android:padding="6dip">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="6dip"

        android:src="@drawable/icon" />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="fill_parent">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"

            android:gravity="center_vertical"
            android:text="My Application" />

        <TextView  
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" 

            android:singleLine="true"
            android:ellipsize="marquee"
            android:text="Simple application that shows how to use RelativeLayout" />

    </LinearLayout>

</LinearLayout>

<!-- Easy AdSenser V2.37 --><!-- Post[count: 2] -->

尽管可以通过Linearlayout实现我们所预想的结果,但是在这里存在一个优化的问题,尤其是针对为大量Items。比较RelativeLayout和LinearLayout,在资源利用上前者会占用更少的资源而达到相同的效果,以下是用RelativeLayout实现的代码:

?[Copy to clipboard] View Code XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"

    android:padding="6dip">

    <ImageView
        android:id="@+id/icon"

        android:layout_width="wrap_content"
        android:layout_height="fill_parent"

        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="6dip"

        android:src="@drawable/icon" />

    <TextView  
        android:id="@+id/secondLine"

        android:layout_width="fill_parent"
        android:layout_height="26dip" 

        android:layout_toRightOf="@id/icon"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"

        android:singleLine="true"
        android:ellipsize="marquee"
        android:text="Simple application that shows how to use RelativeLayout" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"

        android:layout_toRightOf="@id/icon"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_above="@id/secondLine"
        android:layout_alignWithParentIfMissing="true"

        android:gravity="center_vertical"
        android:text="My Application" />

</RelativeLayout>

针对RelativeLayout有一点需要注意,因为它内部是通过多个View之间的关系而确定的框架,那么当其中某一个View因为某些需要调用GONE来完全隐藏掉后,会影响与其相关联的Views。Android为我们提供了一个属性 alignWithParentIfMissing 用于解决类似问题,当某一个View无法找到与其相关联的Views后将依据alignWithParentIfMissing的设定判断是否与父级View对齐。

下边是两种不同layout在Hierarchy Viewer中的层级关系图:

ui_layout_03

<?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"> <ImageView android:id="@+id/show_pictures" android:layout_width="match_parent" android:layout_height="match_parent"/> </RelativeLayout> <?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"> <androidx.viewpager.widget.ViewPager android:id="@+id/change_page" android:layout_width="wrap_content" android:layout_height="wrap_content"> </androidx.viewpager.widget.ViewPager> </RelativeLayout> <?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"> <TextureView android:id="@+id/textureView" android:layout_width="match_parent" android:layout_height="match_parent" /> <ImageButton android:id="@+id/recording" android:layout_width="50dp" android:layout_height="50dp" android:src="@drawable/ic_launcher_background" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="50dp" /> <ImageView android:id="@+id/image_show" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentBottom="true" android:layout_marginBottom="50dp" android:layout_marginStart="50dp" /> <ImageButton android:id="@+id/change" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginEnd="50dp" android:layout_marginBottom="50dp" android:layout_alignParentEnd="true" /> <Chronometer android:id="@+id/timer" android:textColor="#f00" android:layout_width="match_parent" android:layout_height="wrap_content" android:format="%s" android:gravity="center" android:textSize="40sp" /> </RelativeLayout> <?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"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="pemission" /> <TextureView android:id="@+id/textureView" android:layout_width="match_parent" android:layout_height="match_parent" /> <ImageButton android:id="@+id/takePicture" android:layout_width="50dp" android:layout_height="50dp" android:src="@drawable/ic_launcher_foreground" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="50dp" /> <ImageView android:id="@+id/image_show" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentBottom="true" android:layout_marginLeft="50dp" android:layout_marginBottom="50dp" /> <ImageButton android:id="@+id/change" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_marginRight="50dp" android:layout_marginBottom="50dp" android:src="@drawable/ic_launcher_foreground" /> </RelativeLayout> 可以分析
11-27
将fragment_map.xml修改为<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.map.MapFragment"> <TextView android:id="@+id/text_map" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:textAlignment="center" android:textSize="11sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.85" /> <EditText android:id="@+id/map_input1" android:layout_width="0dp" android:layout_height="wrap_content" android:hint="请输入起点" android:minHeight="48dp" android:textSize="16sp" android:layout_marginLeft="10dp" android:layout_marginRight="110dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.1" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0" /> <EditText android:id="@+id/map_input2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="110dp" android:hint="请输入终点" android:minHeight="48dp" android:textSize="16sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.008" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.07" /> <Button android:id="@+id/map_search" android:layout_width="wrap_content" android:layout_height="80dp" android:text="搜索" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.95" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.01" /> </androidx.constraintlayout.widget.ConstraintLayout> fragment_home.xml修改为<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.home.HomeFragment"> <TextView android:id="@+id/text_home" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:textAlignment="center" android:textSize="11sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.85" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/bus" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.45"/> <EditText android:id="@+id/home_input" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="110dp" android:hint="请输入需要查询的公交线路或站点" android:minHeight="48dp" android:textSize="16sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.1" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.05" /> <Button android:id="@+id/home_search" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="搜索" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.95" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.05" /> </androidx.constraintlayout.widget.ConstraintLayout>
10-13
你给的代码本身是这样的:package com.example.bus; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.amap.api.maps.AMap; import com.amap.api.maps.CameraUpdateFactory; import com.amap.api.maps.MapView; import com.amap.api.maps.UiSettings; import com.amap.api.maps.model.LatLng; import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; import com.amap.api.services.core.LatLonPoint; import com.amap.api.services.core.PoiItem; import com.amap.api.services.poisearch.PoiResult; import com.amap.api.services.poisearch.PoiSearch; import java.util.ArrayList; import java.util.List; public class SearchResultActivity extends AppCompatActivity implements PoiSearch.OnPoiSearchListener { private static final String TAG = "SearchResultActivity"; private static final long SEARCH_DEBOUNCE_DELAY = 800; // 防抖时间 ms private EditText searchInput; private Button searchBtn, goToBtn; private RecyclerView resultListView; private ProgressBar progressBar; private List<PoiItem> poiList = new ArrayList<>(); private ResultAdapter adapter; private PoiSearch poiSearch; // 地图相关 private MapView mapView; private AMap aMap; private Marker selectedMarker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search_result); // 设置 ActionBar 返回按钮 if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle("搜索地点"); } initViews(); setupMap(savedInstanceState); setupSearch(); } private void initViews() { searchInput = findViewById(R.id.search_input); searchBtn = findViewById(R.id.search_btn); resultListView = findViewById(R.id.result_list); goToBtn = findViewById(R.id.btn_go_to); progressBar = findViewById(R.id.progress_bar); goToBtn.setEnabled(false); } private void setupMap(Bundle savedInstanceState) { mapView = findViewById(R.id.map_view); mapView.onCreate(savedInstanceState); if (aMap == null) { aMap = mapView.getMap(); UiSettings uiSettings = aMap.getUiSettings(); uiSettings.setZoomControlsEnabled(true); uiSettings.setCompassEnabled(true); uiSettings.setScrollGesturesEnabled(true); aMap.setOnMapClickListener(latLng -> { if (selectedMarker != null) selectedMarker.remove(); selectedMarker = aMap.addMarker(new MarkerOptions() .position(latLng) .title("选中位置")); goToBtn.setEnabled(true); }); // 默认定位到北京 aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.909186, 116.397411), 10f)); } } private void setupSearch() { String keyword = getIntent().getStringExtra("keyword"); if (keyword != null && !keyword.isEmpty()) { searchInput.setText(keyword); performSearch(keyword); } searchBtn.setOnClickListener(v -> { String text = searchInput.getText().toString().trim(); if (!text.isEmpty()) { performSearch(text); } else { Toast.makeText(this, "请输入关键词", Toast.LENGTH_SHORT).show(); } }); goToBtn.setOnClickListener(v -> { if (selectedMarker != null) { LatLng pos = selectedMarker.getPosition(); navigateToRoute(pos.latitude, pos.longitude, "地图选点"); } else if (!poiList.isEmpty()) { PoiItem item = poiList.get(0); LatLonPoint p = item.getLatLonPoint(); navigateToRoute(p.getLatitude(), p.getLongitude(), item.getTitle()); } else { Toast.makeText(this, "暂无目标位置", Toast.LENGTH_SHORT).show(); } }); } private void navigateToRoute(double lat, double lng, String title) { Intent intent = new Intent(this, RoutePlanActivity.class); intent.putExtra("start_mode", "my_location"); intent.putExtra("target_lat", lat); intent.putExtra("target_lng", lng); intent.putExtra("target_title", title); startActivity(intent); } private long lastSearchTime = 0; /** * 执行搜索(带防抖和取消旧请求机制) */ private void performSearch(String keyword) { long now = System.currentTimeMillis(); if (now - lastSearchTime < SEARCH_DEBOUNCE_DELAY) { Log.d(TAG, "防抖:忽略过于频繁的搜索请求"); return; } lastSearchTime = now; // 取消上一次搜索任务 if (poiSearch != null) { poiSearch.cancel(); poiSearch.setOnPoiSearchListener(null); // 解绑防止内存泄露 } // 显示加载状态 progressBar.setVisibility(View.VISIBLE); goToBtn.setEnabled(false); // 构建查询:关键词、类型(空=所有类别)、城市/范围 PoiSearch.Query query = new PoiSearch.Query(keyword, "", "全国"); // 关键修复:"15" → "" query.setPageSize(20); // 每页数量 query.setPageNum(0); // 第一页 try { poiSearch = new PoiSearch(this, query); poiSearch.setOnPoiSearchListener(this); poiSearch.searchPOIAsyn(); // 异步执行 } catch (Exception e) { Log.e(TAG, "启动搜索失败", e); progressBar.setVisibility(View.GONE); Toast.makeText(this, "搜索启动失败,请检查网络或高德Key", Toast.LENGTH_LONG).show(); } } @Override public void onPoiSearched(PoiResult result, int rCode) { progressBar.setVisibility(View.GONE); // 隐藏加载条 if (rCode == 1000) { if (result != null && result.getPois() != null) { List<PoiItem> pois = result.getPois(); poiList.clear(); poiList.addAll(pois); // 更新UI if (adapter == null) { adapter = new ResultAdapter(poiList, item -> { if (selectedMarker != null) { selectedMarker.remove(); } LatLng latLng = new LatLng(item.getLatLonPoint().getLatitude(), item.getLatLonPoint().getLongitude()); selectedMarker = aMap.addMarker(new MarkerOptions() .position(latLng) .title(item.getTitle())); aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14f)); goToBtn.setEnabled(true); }); resultListView.setLayoutManager(new LinearLayoutManager(this)); resultListView.setAdapter(adapter); } else { adapter.notifyDataSetChanged(); } // 提示空结果 if (pois.isEmpty()) { Toast.makeText(this, "未找到匹配的结果", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this, "找到 " + pois.size() + " 个结果", Toast.LENGTH_SHORT).show(); } goToBtn.setEnabled(!pois.isEmpty()); } else { Toast.makeText(this, "搜索结果为空", Toast.LENGTH_SHORT).show(); } } else { String errorMsg; switch (rCode) { case 17: errorMsg = "高德Key校验失败,请检查AndroidManifest.xml中的key或SHA1绑定"; break; case 27: case 28: errorMsg = "网络连接失败,请检查网络"; break; default: errorMsg = "搜索失败,错误码: " + rCode; break; } Log.e(TAG, "POI搜索错误码: " + rCode); Toast.makeText(this, errorMsg, Toast.LENGTH_LONG).show(); } } @Override public void onPoiItemSearched(PoiItem item, int rCode) { // 单个POI详情回调,此处不需要使用 } // 生命周期方法 @Override protected void onResume() { super.onResume(); mapView.onResume(); } @Override protected void onPause() { super.onPause(); mapView.onPause(); } @Override protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); if (poiSearch != null) { poiSearch.setOnPoiSearchListener(null); // 解绑监听器 } if (selectedMarker != null) { selectedMarker.remove(); } } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); } @Override public boolean onSupportNavigateUp() { onBackPressed(); return true; } } 我暂时先用这个,如果还有问题我再让你改。现在就是我的activity_search_result.xml代码如下:<?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" android:fitsSystemWindows="true" android:layout_marginTop="?attr/actionBarSize"> <!-- 根布局:ConstraintLayout 必须 match_parent 高度才能被 NestedScrollView 正确测量 --> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 🔵 垂直指南线:5%、95% --> <androidx.constraintlayout.widget.Guideline android:id="@+id/guideline_05" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" app:layout_constraintGuide_percent="0.05" /> <androidx.constraintlayout.widget.Guideline android:id="@+id/guideline_15" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" app:layout_constraintGuide_percent="0.15" /> <androidx.constraintlayout.widget.Guideline android:id="@+id/guideline_95" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" app:layout_constraintGuide_percent="0.95" /> <!-- 🔍 输入框 --> <EditText android:id="@+id/search_input" android:layout_width="0dp" android:layout_height="wrap_content" android:hint="请输入需要查询的公交线路或站点" android:textColorHint="#777777" android:textColor="@color/black" android:background="@drawable/rounded_edittext" android:minHeight="48dp" android:textSize="16sp" android:padding="12dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/search_btn" app:layout_constraintHorizontal_chainStyle="packed" app:layout_constraintTop_toTopOf="@id/guideline_05" app:layout_constraintBottom_toTopOf="@id/space_after_search" android:layout_marginStart="16dp" android:layout_marginEnd="8dp" /> <!-- 🔎 搜索按钮 --> <Button android:id="@+id/search_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="搜索" app:layout_constraintTop_toTopOf="@id/guideline_05" app:layout_constraintBottom_toTopOf="@id/space_after_search" app:layout_constraintStart_toEndOf="@id/search_input" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="16dp" /> <!-- ⬛ Space: 搜索栏下方留出 5% 屏幕高度作为间隔 --> <Space android:id="@+id/space_after_search" android:layout_width="match_parent" android:layout_height="0dp" app:layout_constraintTop_toBottomOf="@id/guideline_15" app:layout_constraintBottom_toTopOf="@id/map_view" app:layout_constraintHeight_percent="0.05" /> <!-- 🗺️ 地图视图:占页面 40% 高度 --> <com.amap.api.maps.MapView android:id="@+id/map_view" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintTop_toBottomOf="@id/space_after_search" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHeight_percent="0.4" /> <!-- ⬛ Space: 地图到列表之间的空白 --> <Space android:id="@+id/space_after_map" android:layout_width="match_parent" android:layout_height="0dp" app:layout_constraintTop_toBottomOf="@id/map_view" app:layout_constraintBottom_toTopOf="@id/result_list" app:layout_constraintHeight_percent="0.03" /> <!-- 🔽 RecyclerView:结果列表,占据剩余空间 --> <androidx.recyclerview.widget.RecyclerView android:id="@+id/result_list" android:layout_width="0dp" android:layout_height="wrap_content" android:textColorHint="#777777" android:textColor="@color/black" android:background="@drawable/rounded_edittext" app:layout_constraintTop_toBottomOf="@id/space_after_map" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toTopOf="@id/btn_go_to" android:layout_marginHorizontal="16dp" /> <!-- “到这去”按钮 --> <Button android:id="@+id/btn_go_to" android:layout_width="0dp" android:layout_height="wrap_content" android:text="到这去" android:layout_margin="16dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="@id/guideline_95" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.core.widget.NestedScrollView> 你让我添加 <ProgressBar android:id="@+id/progress_bar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:visibility="gone" />我应该加到哪个位置呢,我希望原本的界面不改变
11-08
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值