我试图在android中实现Textinput布局,我正在使用以下代码段。
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2.45"
android:orientation="horizontal"
>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/TextLabel_floating"
>
<EditText
android:id="@+id/rack_id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:imeOptions="actionDone"
android:gravity="bottom"
android:hint="@string/vin_or_stock_small"
android:paddingBottom="5dp"
android:inputType="textCapCharacters|textNoSuggestions"
android:paddingLeft="10dp"
android:background="@color/transparent"
android:textSize="@dimen/common_edit_text_dimen"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
<!-- <LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:background="@drawable/textbox_right_radius"
android:gravity="center"
android:visibility="gone"
android:id="@+id/searchBtn">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView9"
android:src="@drawable/cc_search"
android:background="@drawable/textbox_grey"
android:layout_gravity="center" />
</LinearLayout>-->
</LinearLayout>
除了具有os版本5.0的设备外,其他所有设备都能正常工作。我尝试了很多样式而且没有用,有人可以帮我解决这个问题
对应的java代码:
mRackId = (EditText) view.findViewById(R.id.rack_id);
activity.getWindow().setSoftInputMode(WindowManager.
LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
mRackId.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
if(mRackId.getText().length()!=0) {
if(NetworkUtils.getInstance().isNetworkAvailable()) {
LoadData(mRackId.getText().toString());
}else {
showErrorDialog(getResources().getString(R.string.network_connection_not_available));
}
}else{
showErrorDialog(getResources().getString(R.string.enter_valid_rack));
}
}
return true;
}
});