0
  • <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
           android:orientation="horizontal"
            android:background="@color/purple_700">
    
            <ImageView
                android:id="@+id/home_scan"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_centerVertical="true"
                android:layout_marginStart="16dp"
                android:src="@mipmap/scan" />
    
            <EditText
                android:id="@+id/home_search_edit"
                android:layout_width="0dp"
                android:layout_height="30dp"
                android:layout_weight="1"
                android:layout_centerVertical="true"
                android:layout_marginStart="16dp"
                android:layout_toEndOf="@id/home_scan"
                android:background="@drawable/shape_home_edt_text"
                android:hint="@string/Search_home_edit_text"
                android:paddingStart="10dp"
                android:textSize="18sp"
                tools:ignore="RtlSymmetry" />
    
            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_centerVertical="true"
                android:layout_marginStart="16dp"
                android:layout_toEndOf="@id/home_search_edit"
                android:src="@mipmap/search" />
        </LinearLayout>
    
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/base_container"/>
    
    </LinearLayout>
    


    1241976390056771584  评论     打赏       大佛
    • 因为没做适配啊

      1139423796017500160  评论     打赏       断点-含光君
      • <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="match_parent">
        
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:background="@color/purple_700">
        
                <ImageView
                    android:id="@+id/home_scan"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:layout_centerVertical="true"
                    android:layout_marginStart="16dp"
                    android:src="@mipmap/scan" />
        
                <EditText
                    android:id="@+id/home_search_edit"
                    android:layout_width="280dp"
                    android:layout_height="30dp"
                    android:layout_centerVertical="true"
                    android:layout_marginStart="16dp"
                    android:layout_toEndOf="@id/home_scan"
                    android:background="@drawable/shape_home_edt_text"
                    android:hint="@string/Search_home_edit_text"
                    android:paddingStart="10dp"
                    android:textSize="18sp"
                    tools:ignore="RtlSymmetry" />
        
                <ImageView
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:layout_centerVertical="true"
                    android:layout_marginStart="16dp"
                    android:layout_toEndOf="@id/home_search_edit"
                    android:src="@mipmap/search" />
            </RelativeLayout>
        
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/base_container"/>
        
        </LinearLayout>
        


        1455082248767291393  评论     打赏       Wang_
        • Wang_  回复 @Wang_
          布局代码没问题啊...
          Wang_ 2022-01-20 17:27   回复 1455082248767291393
        • 阿肥  回复 @Wang_
          为啥没问题 你的是相对布局30dp 280dp 30dp如果全部加起来超过了 就显示在屏幕外了哦 可以放个线性布局看看
          阿肥 2022-01-20 18:09   回复 1382711465131241472
        • 阿肥  回复 @Wang_
          这么简单 同行的话 直接用线性布局更好哦 又不需要调整其他的
          阿肥 2022-01-20 18:11   回复 1382711465131241472
        • Wang_  回复 @阿肥
          不行啊,还是遮住了一部分,dp不是说会根据屏幕自动调整大小吗
          Wang_ 2022-01-20 19:16   回复 1455082248767291393
        • 阿肥  回复 @Wang_
          谁说dp是适配的 你自己屏幕多大 读取计算一下呗 这个问题就是相对布局把它搜索按钮撑到了外面呢
          阿肥 2022-01-21 09:11   回复 1382711465131241472
      • 那么,你的代码是怎么写的呢?不给代码,我们也不能猜出来呀

        1204736502274318336  评论     打赏       A lonely cat
        • Wang_  回复 @A lonely cat
          大佬,代码我发评论区了,嘻嘻
          Wang_ 2022-01-20 17:30   回复 1455082248767291393
        • A lonely cat  回复 @Wang_
          你 home_search_edit 的宽度写死了 但是每个设备的屏幕都不一定一样宽 所以有的控件会挤在一起,甚至挤到屏幕外面去
          A lonely cat 2022-01-20 19:16   回复 1204736502274318336
      相关问题
      幻影~ · 提问
      2024-04-13 20:13 8 2
      幻影~ · 找工作
      2024-04-07 10:44 14 2
      幻影~ · 问题
      2024-03-31 17:20 7 2
      TONYGFX · AOSP
      2024-03-28 17:11 4 2