安卓中经常使用控件遇到问题解决方法(持续更新和发现篇幅)(在textview上加一条线、待续)...
TextView設置最多顯示30個字符。超過部分顯示...(省略號),有人說分別設置TextView的android:signature="true",而且設置android:ellipsize="end";可是我試了。居然成功了,供大家參考
[java]?view plaincopy
TextView是常常會在listview中作數(shù)據(jù)顯示。然而像非常多團購那樣,常常會有什么爆款,打折,原價啥,一個textview就這么被一天線強插而入。
普通情況下我們會想都不想直接在布局文件上加那個線??墒峭Ч]那么好看。福利來了,通過JAVA代碼在上面加一條線。
以下看代碼:直接在文字上加一條線豈不是更好...
[java]?view plaincopy
在scrollview中會常常遇到滑動不兼容的。或者第一次進去的時候位置就混亂了,現(xiàn)也貼出代碼看下:
[java]?view plaincopy
mViewFlow.setFocusable(true);
mViewFlow.setFocusableInTouchMode(true);
mViewFlow.requestFocus();
feedBackText.addTextChangedListener(new TextWatcher() {
private CharSequence temp;
private int selectionStart;
private int selectionEnd;
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
temp = s;
}
public void afterTextChanged(Editable s) {
int number = s.length();// 獲得長度
textNum.setText("" + number + "/1000");
selectionStart = feedBackText.getSelectionStart();
selectionEnd = feedBackText.getSelectionEnd();
if (temp.length() > 1000) {
s.delete(selectionStart - 1, selectionEnd);
int tempSelection = selectionEnd;
feedBackText.setText(s);
feedBackText.setSelection(tempSelection);// 設置光標在最后
}
}
});
設置activity無標題
方法一:
在Manifest.xml中為activity添加屬性:??android:theme="@android:style/Theme.NoTitleBar"
方法二:
在activity的onCreate()中增加:requestWindowFeature(Window.FEATURE_NO_TITLE);
2.設置activity全屏
方法一:
在Manifest.xml中為activity添加屬性:? android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
方法二:
代碼中添加方法:
public void setFullScreen(boolean isFullScreen) {
if (isFullScreen) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
}
true為設置全屏, false非全屏
轉載于:https://www.cnblogs.com/lytwajue/p/7007155.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結
以上是生活随笔為你收集整理的安卓中经常使用控件遇到问题解决方法(持续更新和发现篇幅)(在textview上加一条线、待续)...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何恢复误删的OneNote页面
- 下一篇: 简单易用的MongoDB