片段布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:fitsSystemWindows="true"
android:layout_height="match_parent"
android:background="@drawable/fragments_background"
tools:context=".ui.fragments.BillPaymentFragment">
<LinearLayout
android:id="@+id/wallet"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/wolletColor"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/dimen_50dp"
android:layout_height="@dimen/dimen_50dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/dimen_20dp"
android:background="@drawable/wallet" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginStart="@dimen/dimen_4dp"
android:orientation="vertical">
<TextView
android:id="@+id/wallet_remains"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dimen_10dp"
android:text="3450.00 LKR"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/dimen_16dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wallet_remains"
android:textColor="@color/gray"
android:textSize="@dimen/dimen_12dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:paddingTop="@dimen/dimen_60dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="@dimen/dimen_20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/dimen_10dp"
android:text="Mobile No"
android:textColor="@color/borderAndFont"
android:textSize="@dimen/dimen_20dp"></TextView>
<EditText
android:id="@+id/reload_mobile_number"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="@dimen/dimen_20dp"
android:background="@drawable/rounded_edit_text"
android:gravity="center|center_vertical"
android:hint="@string/mobile_number"
android:inputType="phone"
android:textColor="@color/borderAndFont"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/dimen_10dp"
android:text="@string/amount"
android:textColor="@color/borderAndFont"
android:textSize="@dimen/dimen_20dp"></TextView>
<EditText
android:id="@+id/reload_amount"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/rounded_edit_text"
android:gravity="center|center_vertical"
android:hint="@string/amount_hint"
android:inputType="number"
android:textColor="@color/borderAndFont"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_marginEnd="@dimen/dimen_20dp"
android:layout_marginStart="@dimen/dimen_20dp"
android:gravity="bottom"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/cancelBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen_10dp"
android:layout_marginEnd="@dimen/dimen_6dp"
android:layout_marginTop="@dimen/dimen_10dp"
android:layout_weight="1"
android:background="@drawable/secondary_button"
android:text="Cancel"
android:textColor="@color/white" />
<Button
android:id="@+id/btn_proceed"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen_10dp"
android:layout_marginStart="@dimen/dimen_6dp"
android:layout_marginTop="@dimen/dimen_10dp"
android:layout_weight="1"
android:background="@drawable/primary_button"
android:text="Proceed"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
AndroidManifest.xml
<activity
android:windowSoftInputMode="adjustResize"
android:name=".ui.main.MainActivity"
android:screenOrientation="sensorPortrait"
android:theme="@style/AppTheme.NoActionBar"></activity>
我上面有一个片段调用重载片段。父活动是MainActivity,在此我附加了与活动相关的清单文件代码。当我单击edittext时,底部按钮用键盘覆盖了edittext字段。在这里,我在清单文件中添加了android:fitsSystemWindows属性。我的代码有什么遗漏吗?谢谢。
答案 0 :(得分:1)
在主要活动中添加android:fitsSystemWindows="true
和android:windowSoftInputMode="adjustResize"
无效。
您必须将android:fitsSystemWindows="true
添加到该特定片段xml 文件的父布局中。在java
中Fragment
的{{1}}类中,您必须像这样添加onCreateView
。
windowSoftInputMode
希望这对您有用。让我知道您是否有任何问题。
答案 1 :(得分:0)
x = input("give me a string: ")
def unique(x):
seen = []
repeated = []
for char in x:
if char in seen:
repeated.append(char)
else:
seen.append(char)
for idx, char in enumerate(x):
if char not in repeated:
return idx
return -1
print(unique(x))