我创建了从 AppCompatEditText 扩展的类 ComplexEditText。我确定了我的背景变体:
setBackground(getResources().getDrawable(R.drawable.backgroundedittext));
我解决了填充:
setPadding((int) (16 * scale), (int) (10 * scale), (int) (17 * scale), (int) (13 * scale));
我创建了清除输入文本的按钮
mClearButtonImage = ResourcesCompat.getDrawable(getResources(), R.mipmap.delete_button, null);
但问题是当我触摸我的自定义视图(从 AppCompatEditText 扩展)时,键盘没有打开。我试过:
setClickable(true)
setFocusable(true)
setShowSoftInputOnFocus(true);
nputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
我在 AndroidManifes.xml 中安顿下来:
android:windowSoftInputMode="adjustResize"
它也不起作用。键盘没有出现。
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.royallogistics.yegor.royallogistics">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application
android:name=".service.AppChannel"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".LoginActivity" />
<activity android:name=".SubordersDinamicsFields"
android:windowSoftInputMode="stateVisible">
</activity>
哔哔one
相关分类