有时候textview中写文字超过一行虽然会换行,但是文本框会向下移动一些距离,不在textview中,例如:
本来的文本框内容应该在:
这里原因是什么我也不太清楚,但是对比了其他的不会偏移的view最后发现,只要在view外侧加上一个layout就可以
原本的代码是:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/run_set_name"
android:layout_width="0dp"
android:layout_height="36dp"
android:layout_weight="0.4"
android:background="@drawable/data_table_text_shape"
android:gravity="center"
android:minHeight="36dp"
android:text="@string/parameter_name"
android:textColor="@color/black_color"
android:textSize="15sp" />
<TextView
android:id="@+id/run_set_value"
android:layout_width="0dp"
android:layout_height="36dp"
android:layout_weight="0.6"
android:background="@drawable/data_table_text_shape"
android:gravity="center"
android:minHeight="35dp"
android:text="11111111111111111111"
android:textColor="@color/black_color"
android:textSize="15sp" />
</LinearLayout>
之后在两个view上面加了分别加了两个layout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0.6" >
<TextView
android:id="@+id/run_set_name"
android:layout_width="match_parent"
android:layout_height="36dp"
android:background="@drawable/data_table_text_shape"
android:gravity="center"
android:minHeight="36dp"
android:text="@string/parameter_value"
android:textColor="@color/black_color"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0.4" >
<TextView
android:id="@+id/run_set_value"
android:layout_width="match_parent"
android:layout_height="36dp"
android:background="@drawable/data_table_text_shape"
android:gravity="center"
android:minHeight="36dp"
android:text="@string/parameter_value"
android:textColor="@color/black_color"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
就正常显示了