TextView tv1 = new TextView(this);
tv1.setPadding(5, 0, 5, 0);
tv1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
tv1.setBackgroundColor(Color.parseColor("#0099cc"));
tv1.setTextColor(Color.WHITE);
tv1.setTextSize(11);
tv1.setGravity(Gravity.LEFT | Gravity.BOTTOM);
tv1.setText("Test1");
ll.addView(tv1);
TextView tv2 = new TextView(this);
tv2.setPadding(5, 0, 5, 0);
tv2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
tv2.setBackgroundColor(Color.parseColor("#0099cc"));
tv2.setTextColor(Color.WHITE);
tv2.setTextSize(11);
tv2.setGravity(Gravity.LEFT | Gravity.BOTTOM);
tv2.setText("Test2");
ll.addView(tv2);
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,在这个代码的平静中,我设置了TextView背景颜色.我想要做的是我想将它们彼此分开TextView,这样它们的背景颜色就会被一条线分开.我不希望他们连接.据我了解,如果可以设定利润率,就有可能这样做TextView,但据我所知,TextView我们无法做到这一点.
我正在尝试创建一个非常基本的聊天屏幕,其中ListView显示文本,底部是EditText,EditText右侧是"发送"按钮.一切都很实用,但当我点击EditText时,虚拟键盘会覆盖它.屏幕平移一点但不足以在键盘上方可见.我的清单中有"adjustPan"标签,并且还尝试了"adjustResize"标签无效.我猜这与我的布局设置方式有关,但老实说我没有任何线索.请帮忙!
当前布局......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/android:list"
android:layout_height="0dip"
android:layout_width="fill_parent"
android:layout_weight="1"
android:stackFromBottom="true">
</ListView>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/sendMessageBox"
android:focusable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical"
android:maxLines="4"
android:text=""
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:maxLength="1000"
android:hint="Type your message..."
android:imeOptions="actionSend"/>
<Button android:id="@+id/sendMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Send"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
android android-manifest android-layout android-softkeyboard
我想在EditText和Soft Keyboard之间添加10dp的边距.
这是我的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>
Run Code Online (Sandbox Code Playgroud)
这是我的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;
}});
Run Code Online (Sandbox Code Playgroud)
我正在使用viewpager和全屏主题.以下EditText位于我的第3个片段中.
我用android:windowSoftInputMode="adjustResize|adjustPan"和android:windowSoftInputMode="adjustResize",但什么都没有发生.
android android-keypad android-edittext android-fragments android-viewpager
我有一个问题与EditTexts的软键盘重叠部分.
当我单击我的EditTexts时,软键盘出现在文本的正下方,这意味着文本框的一部分未显示,因为软键盘与其重叠.
有任何想法如何增加EditText和软键盘之间的距离?