arcadefire / nice-spinner

A nice spinner for Android
Apache License 2.0
2.85k stars 445 forks source link

The item displays normal on the first click, and abnormal on the next click #121

Closed lhhseraph closed 5 years ago

lhhseraph commented 5 years ago

The item displays normal on the first click, and abnormal on the next click

The item height and font size have changed

lhhseraph commented 5 years ago

360截图18460319373162 360截图16800415105124130

arcadefire commented 5 years ago

Can you show me some code? Maybe the layout XML config as well?

lhhseraph commented 5 years ago

Thank you for your reply. The following are layout and Java code

<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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:focusable="true" android:focusableInTouchMode="true" android:gravity="center_horizontal" android:orientation="vertical" android:padding="16dp">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="@drawable/frame_stroke_bg"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        style="@style/FrameTitleTextH"
        android:text="检验日期"/>

    <TextView
        android:id="@+id/tvDate"
        style="@style/ContentTextH"
        android:layout_width="300dp"
        android:text="2016-11-22"/>

    <TextView
        style="@style/FrameTitleTextH"
        android:text="检验设备"/>

    <com.production.flow.ui.widget.ClearableEditText
        android:id="@+id/etDev"
        style="@style/EditText"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_weight="2.31"
        android:hint="请输入"
        android:inputType="text"/>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="@drawable/frame_stroke_bg"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        style="@style/FrameTitleTextH"
        android:text="批次号"/>

    <com.production.flow.ui.widget.ClearableEditText
        android:id="@+id/etBatch"
        style="@style/EditText"
        android:layout_width="300dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:hint="请输入"
        android:inputType="text"/>
    <TextView
        style="@style/FrameTitleTextH"
        android:text="TAL卷号"/>

    <com.production.flow.ui.widget.ClearableEditText
        android:id="@+id/etTalReelNo"
        style="@style/EditText"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_weight="1"
        android:maxLength="1"
        android:hint="请输入"
        android:inputType="number"/>

    <TextView
        style="@style/FrameTitleTextH"
        android:text="产品类型"/>

    <org.angmarch.views.NiceSpinner
        android:id="@+id/spProType"
        style="@style/TextStyle.MediumNormal"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="right"/>

</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_marginTop="12dp"
    android:background="@drawable/frame_stroke_bg"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        style="@style/FrameTitleTextH"
        android:text="取样数(枚)"/>

    <com.production.flow.ui.widget.ClearableEditText
        android:id="@+id/etSampleNumber"
        style="@style/EditText"
        android:layout_width="300dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:hint="请输入"
        android:inputType="number"/>

    <TextView
        style="@style/FrameTitleTextH"
        android:text="合格数"/>

    <com.production.flow.ui.widget.ClearableEditText
        android:id="@+id/etPassNumber"
        style="@style/EditText"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_weight="1"
        android:hint="请输入"
        android:inputType="number"/>

    <TextView
        style="@style/FrameTitleTextH"
        android:text="不合格数"/>

    <com.production.flow.ui.widget.ClearableEditText
        android:id="@+id/etNoPassNumber"
        style="@style/EditText"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_weight="1"
        android:hint="请输入"
        android:inputType="number"/>

</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="@drawable/frame_stroke_bg"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        style="@style/FrameTitleTextH"
        android:text="不合格表象"/>

    <com.production.flow.ui.widget.ClearableEditText
        android:id="@+id/etNoPassInfo"
        style="@style/EditText"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_weight="1"
        android:hint="请输入"
        android:inputType="text"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="@drawable/frame_stroke_bg"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        style="@style/FrameTitleTextH"
        android:text="判定结果"/>

    <lib.kingja.switchbutton.SwitchMultiButton
        android:id="@+id/sbResult"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        app:selectedColor="@color/chelsea_cucumber"
        app:selectedTab="0"
        app:strokeRadius="1dp"
        app:strokeWidth="1dp"
        app:switchTabs="@array/pass_switch_yn"
        app:textSize="@dimen/NormalSmall_text"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="64dp"
    android:layout_marginTop="12dp"
    android:background="@drawable/frame_stroke_corners_bg"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        style="@style/FrameTitleTextH"
        android:text="质检员"/>
    <TextView
        android:id="@+id/tvOpMan"
        style="@style/TextStyle.NormalSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:paddingLeft="8dp"
        android:text="点击选择人员"
        android:textColor="@color/result_gray"/>

    <TextView
        style="@style/FrameTitleTextH"
        android:text="备   注"/>
    <com.production.flow.ui.widget.ClearableEditText
        android:id="@+id/etMemo"
        style="@style/EditText"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_weight="1"
        android:inputType="text"/>

</LinearLayout>

<TextView
    android:id="@+id/tvChangeTips"
    style="@style/TextStyle.Normal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    android:text="修改提示:1、如需修改批次号,请修改后仔细核对! 2、修改后需要重新编辑操作员,方能提交数据!"
    android:textColor="@color/home_wly_red"
    android:visibility="gone"/>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal">
    <TextView
        android:id="@+id/btnSubmit"
        style="@style/TextStyle.NormalSmall"
        android:layout_width="120dp"
        android:layout_height="36dp"
        android:layout_gravity="right|bottom"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        android:background="@drawable/login_confirm_btn_selector"
        android:gravity="center"
        android:text="提交"
        android:textColor="@color/white"/>
</FrameLayout>

String[] types = { "TAL半成品", "CL半成品", "成品", "原材料" };
String[] results = { "合格", "不合格" };
String type;

void initView() {
    tvDate.setText(TimeUtils.getNowString(new SimpleDateFormat("yyyy-MM-dd")));
    spProType.attachDataSource(Arrays.asList(types));

    // // 适配器
    // ArrayAdapter arr_adapter = new ArrayAdapter<String>(this, R.layout.simple_spinner_item,
    // Arrays.asList(types));
    // // 设置样式
    //// arr_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // spProType.setAdapter(arr_adapter);

    type = types[0];
    spProType.setOnSpinnerItemSelectedListener(new OnSpinnerItemSelectedListener() {
        @Override
        public void onItemSelected(NiceSpinner parent, View view, int position, long id) {
            type = types[position];
        }
    });
    spProType.setSelectedIndex(0);

    // // 适配器
    // ArrayAdapter arr_adapter = new ArrayAdapter<String>(this, R.layout.simple_spinner_item,
    // Arrays.asList(types));
    // // 设置样式
    //// arr_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // spProType.setAdapter(arr_adapter);
    // // 加载适配器
    // spProType.setAdapter(arr_adapter);
    // // 添加事件Spinner事件监听
    // spProType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    // @Override
    // public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
    // type = types[i];
    // }
    //
    // @Override
    // public void onNothingSelected(AdapterView<?> adapterView) {
    //
    // }
    // });
    // spProType.setSelection(0);

}
lhhseraph commented 5 years ago

Find out why, in the theme Settings < item name = "android: fitsSystemWindows" > true < / item >