当前位置:首页 » 安卓系统 » android滚动显示

android滚动显示

发布时间: 2022-05-06 04:52:15

㈠ 怎么在android中出现滚动界面

使用ScrollView即可。

例如:

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:scrollbars="vertical"

android:fadingEdge="vertical"

>

android:orientation="vertical" android:layout_width="fill_parent"

android:layout_height="wrap_content" android:padding="10dip"

android:scrollbars="vertical"

>

注意的是:ScrollView也是一个layout布局,可以让它的内容数据显示不下的时候出现滚动条。但是不能在ScrollView中放置多个组件,Scrollview只能包裹一个子元素。可以在Scrollview中放置一个LinearLayout或其他layout来放置更多组件(Layout可以嵌套的)。

安卓系统桌面循环滚动桌面设置的

1、手机设置”的“辅助功能”中有选择是否“桌面循环”。
2、在原生的android源码上添加这一功能。
思路:先把界面做出来,再将是否选择的值存到系统的(adb shell进入)data/data/com.android.providers.settings/databases/settings.db数据库中的system表中,
然后在Launch2的源码中取得数据库中是否选择循环桌面来执行相关代码。
先做UI:
在settings源码中的accessibility_settings.xml文件中添加一个checkbox:
java代码
android:key="launch_repeat"
android:title="@string/launch_repeat_title"
android:persistent="false"/>

在settings源码的res中添加相关的代码:
在values/string.xml中添加(英文显示):
Launch Repeat
在values-zh-rCN/string.xml中添加(中文显示):
"循环桌面"
在settings源码的AccessibilitySettings.java中的OnCreate中添加:
java代码
/*****************************************/

mLaunchRepeat=(CheckBoxPreference) findPreference(
LAUNCH_REPEAT);
int LaunchRepeat=Settings.System.getInt(this.getContentResolver(),
"launch_repeat",0);//取出是否被选择
if(LaunchRepeat==1)//如果被选择,那么下次打开setting时就勾选
mLaunchRepeat.setChecked(true);
else
mLaunchRepeat.setChecked(false);//如果没被选择,那么下次打开setting时就不勾选
/*****************************************/
当然还要定义几个量:
private final String LAUNCH_REPEAT =
"launch_repeat";
private CheckBoxPreference mLaunchRepeat;

在onPreferenceTreeClick函数中添加:
java代码
//add by xxnan

if(LAUNCH_REPEAT.equals(key))
{
Settings.System.putInt(getContentResolver(),
"launch_repeat",
((CheckBoxPreference) preference).isChecked()?
1:0);//将是否选择存到系统的system表中
}
//add by xxnan

如果做好了之后当点击选择“桌面循环时”可以到(adb shell进入)data/data/com.android.providers.settings/databases下的settings.db数据库(sqlite3 settings.db)的system
表中看到33|launch_repeat|1(select * from system;)。
到这里就完成了将数据存到系统system表中以及UI,接下来就是在Launch2源码中去取这个值(是否循环)。
到Launcher2源码中去找到Workspace.java文件,在里面有相应的修改:
在onTouchEvent中,之前有修改循环,如下:
java代码
case MotionEvent.ACTION_UP:

if (mTouchState == TOUCH_STATE_SCROLLING) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
final int velocityX = (int)
velocityTracker.getXVelocity(mActivePointerId);
final int screenWidth = getWidth();
final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
final float scrolledPos = (float) mScrollX / screenWidth;
Log.i("velocityX","velocityX="+velocityX+"whichScreen="+whichScreen);
/***********************************************/
//modifided by xxnan
if (velocityX > SNAP_VELOCITY) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
Log.i("numscreen","numscreen="+mCurrentScreen);
/* final int bound = scrolledPos < whichScreen ?
( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount():
mCurrentScreen;*/
final int bound =( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount()
;
Log.i("numscreen","bound="+bound);
snapToScreen( bound, velocityX, true);
} else if (velocityX < -SNAP_VELOCITY ) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
/*final int bound = scrolledPos > whichScreen ?
( mCurrentScreen + 1 )% getChildCount(): mCurrentScreen;*/
final int bound = ( mCurrentScreen + 1 )% getChildCount() ;
snapToScreen(bound, velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}
/***********************************************/
//下面是原生代码
/*if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
final int bound = scrolledPos < whichScreen ?
mCurrentScreen - 1 : mCurrentScreen;
snapToScreen(Math.min(whichScreen, bound), velocityX, true);
} else if (velocityX < -SNAP_VELOCITY && mCurrentScreen <
getChildCount() - 1) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
final int bound = scrolledPos > whichScreen ?
mCurrentScreen + 1 : mCurrentScreen;
snapToScreen(Math.max(whichScreen, bound), velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}*/
}
mTouchState = TOUCH_STATE_REST;
mActivePointerId = INVALID_POINTER;
releaseVelocityTracker();
break;

那么就要在修改的地方加一个判断,如果system中取得的值是1,就可以循环,如果是0,就不能。
代码修改如下:
java代码
case MotionEvent.ACTION_UP:

if (mTouchState == TOUCH_STATE_SCROLLING) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
final int velocityX = (int)
velocityTracker.getXVelocity(mActivePointerId);
final int screenWidth = getWidth();
final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
final float scrolledPos = (float) mScrollX / screenWidth;
Log.i("velocityX","velocityX="+velocityX+"whichScreen="+whichScreen);
/***********************************************/
//modifided by xxnan 2013-1-9
launch_repeat=Settings.System.getInt(mContext.getContentResolver(),
"launch_repeat",0);//取出system表中“launch_repeat”的值
Log.i(" launch_repeat"," launch_repeat="+ launch_repeat);
if(launch_repeat==1)//如果是1,就循环,也就是之前已经改好的
{
if (velocityX > SNAP_VELOCITY) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
Log.i("numscreen","numscreen="+mCurrentScreen);
/* final int bound = scrolledPos < whichScreen ?
( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount():
mCurrentScreen;*/
final int bound =( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount()
;
Log.i("numscreen","bound="+bound);
snapToScreen( bound, velocityX, true);
} else if (velocityX < -SNAP_VELOCITY ) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
/*final int bound = scrolledPos > whichScreen ?
( mCurrentScreen + 1 )% getChildCount(): mCurrentScreen;*/
final int bound = ( mCurrentScreen + 1 )% getChildCount() ;
snapToScreen(bound, velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}
}
else//如果是0,那么就是原生代码,不循环
{
if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
final int bound = scrolledPos < whichScreen ?
mCurrentScreen - 1 : mCurrentScreen;
snapToScreen(Math.min(whichScreen, bound), velocityX, true);
} else if (velocityX < -SNAP_VELOCITY && mCurrentScreen <
getChildCount() - 1) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
final int bound = scrolledPos > whichScreen ?
mCurrentScreen + 1 : mCurrentScreen;
snapToScreen(Math.max(whichScreen, bound), velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}
}
/***********************************************/
//下面是原生代码
/*if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
final int bound = scrolledPos < whichScreen ?
mCurrentScreen - 1 : mCurrentScreen;
snapToScreen(Math.min(whichScreen, bound), velocityX, true);
} else if (velocityX < -SNAP_VELOCITY && mCurrentScreen <
getChildCount() - 1) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
final int bound = scrolledPos > whichScreen ?
mCurrentScreen + 1 : mCurrentScreen;
snapToScreen(Math.max(whichScreen, bound), velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}*/
}
mTouchState = TOUCH_STATE_REST;
mActivePointerId = INVALID_POINTER;
releaseVelocityTracker();
break;

当然这里面也要定义几个量,以及导入几个包:
导入包:
//add by xxnan
import android.content.ContentResolver;//从system表中取数据
import android.provider.Settings;
定义变量:
private int launch_repeat;//取得是否循环的值
到这里就全部修改好了,还有就是编译一下源码中的package/apps的Launch2和Settings的源码,将生成的out/target/。。。/system/app下的
Launch2.apk和Settings.apk替换手机里system/app的这两个apk就可以了。

㈢ 想在android手机屏幕上实现文字的滚动显示

Animation ani = AnimationUtil.loadAnimation(R.anim.youranime);
yourWidget.startAnimation(ani);

用xml构造animation请自行查看api手册..

㈣ Android中这种类似的滚动界面是如何实现的

第一,在布局文件中添加一个Button,单击Button,弹出菜单 第二,我们给Button添加一个单击事件popupMenu,接下来,就在java文件中实现该方法。 第三,我们加载了一个menu文件“popupmenu” 第四,别忘了在onCreate方法中初始化Button。

㈤ android textview 怎么实现文字滚动

TextView实现文字滚动需要以下几个要点:
1.文字长度长于可显示范围:android:singleLine="true"
2.设置可滚到,或显示样式:android:ellipsize="marquee"
3.TextView只有在获取焦点后才会滚动显示隐藏文字,因此需要在包中新建一个类,继承TextView。重写isFocused方法,这个方法默认行为是,如果TextView获得焦点,方法返回true,失去焦点则返回false。跑马灯效果估计也是用这个方法判断是否获得焦点,所以把它的返回值始终设置为true。ellipsize属性
设置当文字过长时,该控件该如何显示。有如下值设置:”start”—–省略号显示在开头;”end”——省略号显示在结尾;”middle”—-省略号显示在中间;”marquee” ——以跑马灯的方式显示(动画横向移动)marqueeRepeatLimit属性
在ellipsize指定marquee的情况下,设置重复滚动的次数,当设置为marquee_forever时表示无限次。focusable属性
能否获得焦点,同样focusableInTouchMode应该是滑动时能否获得焦点

㈥ Android scrollview滚动条显示不出来怎么办

正好也遇到这个问题,刚看到的分享下 android:background 设置背景色/背景图片。可以通过以下两种方法设置背景为透明:”@android:color/transparent”和”@null”。注意TextView默认是透明的,不用写此属性,但是Buttom/ImageButton/ImageView想透

㈦ 》android 编程中如何实现页面滚动...是用ScrollView吗 具体怎么实现...

1L正解。就是在你现在的xml里面所有的控件外面包裹一层ScrollView,这样ScrollView里面的所有显示的内容都是可以滚动查看的。

㈧ 如何在android中实现,一幅一幅图片 通过手势滚动显示,并且可以两个手指触控来缩放图片

总得一句话要重写onTouchEvent

1.手势滚动有很多方法:
可用viewpager实现view的左右滑屏,也可以用ViewFlipper,还有笨方法就是一个imageview,获取按下抬起坐标,判断左滑右滑,然后set另一张图片进去。

2.缩放也有很多做法
正统的做法是把imageview的属性scaleType设置为matrix(矩阵),然后获取滑动手势,来操作矩阵获得缩放的效果

㈨ android 如何让多条数据在一个textview中垂直滚动显示

Android中我们为了实现文本的滚动可以在ScrollView中嵌入一个TextView,其实TextView自己也可以实现多行滚动的,毕竟ScrollView必须只能有一个直接的子类布局。只要在layout中简单设置几个属性就可以轻松实现
<TextView
android:id="@+id/tvCWJ"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"<!--垂直滚动条-->
android:singleLine="false"<!--实现多行-->
android:maxLines="15"<!--最多不超过15行-->
android:textColor="#FF0000"
/>
当然我们为了让TextView动起来,还需要用到TextView的setMovementMethod方法设置一个滚动实例,代码如下:
TextViewtvAndroid123=(TextView)findViewById(R.id.tvCWJ);
tvAndroid123.setMovementMethod(ScrollingMovementMethod.getInstance());//Android开发网提示相关的可以查看SDK中android.text.method分支了解更多

㈩ android LinearLayout滚动条自动显示

这样的功能不适合用LinearLayout来实现,应当使用 ScrollView。
追踪最末尾的方法是,每次ScroolView的内容改变时,都执行一下这一句:

scrollText.post(new Runnable() {
public void run() {
scrollText.fullScroll(ScrollView.FOCUS_DOWN);
}
});

这里假设这个ScroolView是scrollText。

热点内容
linuxcftp服务器 发布:2025-05-14 23:58:18 浏览:716
探岳什么配置才有驾驶模式选择 发布:2025-05-14 23:53:17 浏览:143
如何在手机上看无限流量密码 发布:2025-05-14 23:43:31 浏览:114
19投篮脚本 发布:2025-05-14 23:36:57 浏览:513
编译器怎么处理c变长数组 发布:2025-05-14 23:31:46 浏览:663
存折每天可以输错多少次密码 发布:2025-05-14 23:22:06 浏览:909
安卓手机怎么找微信隐藏对话 发布:2025-05-14 23:07:47 浏览:338
怎么查看泰拉服务器ip 发布:2025-05-14 23:03:29 浏览:74
c语言学生成绩查询系统 发布:2025-05-14 22:58:30 浏览:6
怎么进别人的服务器 发布:2025-05-14 22:45:55 浏览:774