gpt4 book ai didi

android - 如何在 EditText 和软键盘之间添加边距?

转载 作者:IT老高 更新时间:2023-10-28 22:10:10 27 4
gpt4 key购买 nike

我想在 EditText 和软键盘之间添加 10dp 的边距。

enter image description here这是我的 XML:

<RelativeLayout
android:id="@+id/BottomLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@drawable/bottom_glass" >

<EditText
android:id="@+id/message"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/grey"
android:ems="10"
android:layout_marginBottom="10dp"
android:hint="Enter Message"
android:textColor="#ffffff" >


</EditText>

<ImageButton
android:id="@+id/sendMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/message"
android:background="@android:color/transparent"
android:src="@drawable/sendselector" />

<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/message"
android:background="@android:color/transparent"
android:src="@drawable/sendmediaselector" />

</RelativeLayout>

这是我的 onCreate() :

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
messageText.setOnTouchListener(new OnTouchListener(){

@Override
public boolean onTouch(View v, MotionEvent event) {
((Swipe)getActivity()).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
return false;
}});

我正在使用 viewpager 和全屏主题。以下 EditText 在我的第三个 fragment 中。

我使用了 android:windowSoftInputMode="adjustResize|adjustPan"android:windowSoftInputMode="adjustResize",但什么也没发生。

最佳答案

我发现 paddingBottom 的属性会影响 editText 和键盘之间的距离。你可以这样做:

<RelativeLayout   
android:layout_width="match_parent"
android:layout_height="110dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/your_edit_text_background"/>
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"/>
</RelativeLayout>

这将使您的键盘边距 EditText 10dp

关于android - 如何在 EditText 和软键盘之间添加边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21441372/

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