如何通过单击一个按钮从右到左和左右移动选取框文本,我怎么能做到这一点,任何人都可以帮助我?Android:如何通过点击一个按钮从右到左和左右移动选取框文本
2
A
回答
0
检查了这一点:
<ScrollView
android:id="@+id/sc"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/btn"
android:layout_below="@+id/txt"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Thanks Christian but I am trying to get my text to scroll downwards automatically I am able to scroll horizontally fine."
android:textSize="50dp" />
</ScrollView>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Scroll"/>
在活动写:
ScrollView scrollView=(ScrollView) findViewById(R.id.sc);
Button button=(Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
scrollView.post(new Runnable() {
public void run() {
scrollView.smoothScrollTo(0, scrollView.getBottom());
}
});
}
});
2
下面的例子
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/mywidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:lines="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="#ff4500"
android:text="Simple application that shows how to use marquee, with a long text" />
调用到活动按钮
tv = (TextView) this.findViewById(R.id.tv);
tv.setSelected(true);
7
试试这个;
Animation animationToLeft = new TranslateAnimation(400, -400, 0, 0);
animationToLeft.setDuration(12000);
animationToLeft.setRepeatMode(Animation.RESTART);
animationToLeft.setRepeatCount(Animation.INFINITE);
Animation animationToRight = new TranslateAnimation(-400,400, 0, 0);
animationToRight.setDuration(12000);
animationToRight.setRepeatMode(Animation.RESTART);
animationToRight.setRepeatCount(Animation.INFINITE);
TextView textViewMarqToLeft = (TextView) findViewById(R.id.textViewMarqToLeft);
TextView textViewMarqToRight = (TextView) findViewById(R.id.textViewMarqToRight);
textViewMarqToLeft.setAnimation(animationToLeft);
textViewMarqToRight.setAnimation(animationToRight);
String textLeft = "Left marquue"
String textRight = "Right marquue"
textViewMarqToLeft.setText(textLeft);
textViewMarqToRight.setText(textRight);
3
使用此代码它将工作100%。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/btnbk"
android:orientation="vertical" >
<TextView
android:id="@+id/scrollTxt"
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="8dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Broad way Solution... www.BroadWaySolution.com"
android:textColor="#FFFFFF"
android:textSize="15dp" />
</LinearLayout>
+0
这是我想要的。 – 2015-11-20 09:14:02
+0
@ S.M_Emamian很高兴看到我的答案有用,请将此答案投票 – 2015-11-20 09:33:38
Thanks Dude :) :) – Sourabh 2014-02-15 14:17:53
嘿,高超的工作。 – Kogile 2016-06-10 07:04:33