kos*_*sas 5 android imageview android-layout android-linearlayout android-layout-weight
我遵循了这个示例并设法将fab按钮放置在正确的位置
但是当我按下编辑文本键盘时,会弹出并弄乱布局的权重
我怎样才能使ImageView保持静态,而当键盘打开时它将保持相同的大小?
XML:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ViewA"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="@color/colorPrimary"
android:orientation="horizontal">
<ImageView
android:id="@+id/imgview"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@color/light_blue"
android:scaleType="centerCrop"
android:src="@android:drawable/ic_menu_camera"
android:layout_gravity="top|center_horizontal"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/ViewB"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.3"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/ViewA"
android:clickable="true"
app:layout_anchorGravity="bottom|right"
app:elevation="5dp"
app:pressedTranslationZ="0dp"
android:src="@android:drawable/ic_menu_camera"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
小智 4
这是因为 Android 默认行为是视图将调整大小以为键盘腾出空间。您可以在清单文件中更新 android:windowSoftInputMode --> adjustmentResize、adjustmentPan、adjustmentUnspecified的可能值
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
860 次 |
| 最近记录: |