亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

搞了很久,還是無法實現跑馬燈效果,一行也實現不了。。。怎么搞,也無法定義singline,只能maxline

<TextView
? ?android:layout_width="wrap_content"
? ?android:layout_height="wrap_content"
? ?android:ellipsize="marquee"
? ?android:focusable="true"
? ?android:focusableInTouchMode="true"
? ?android:maxLines="1"
? ?android:text="@string/app_demo"

正在回答

3 回答

我用的也是android studio,但是可以顯示一行哦,另一個控件用了layou_below就不能顯示,所以只有一行可以跑馬,這是我的源碼,你參考下。

android studio初始化先刪掉原來的。xml,重新新建一個在layou叫layou.xml

layou.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ?android:layout_width="match_parent"
? ?android:layout_height="match_parent">

? ?<com.penguin.administrator.marqueetextviewdemon.MarqueeText
? ? ? ?android:id="@+id/textView1"
? ? ? ?android:layout_width="wrap_content"
? ? ? ?android:layout_height="wrap_content"
? ? ? ?android:singleLine="true"
? ? ? ?android:ellipsize="marquee"
? ? ? ?android:focusable="true"
? ? ? ?android:focusableInTouchMode="true"
? ? ? ?android:text="@string/Hello_world"
? ? ? ?android:textSize="18dp"
? ? ? ?/>

MarqueeText.java://創建構造函數按Alt+Lnsert

package com.penguin.administrator.marqueetextviewdemon;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

/**
* Created by Administrator on 2017/7/19.
*/

public class MarqueeText extends android.support.v7.widget.AppCompatTextView{
? ?public MarqueeText(Context context) {
? ? ? ?super(context);
? ?}

? ?public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr) {
? ? ? ?super(context, attrs, defStyleAttr);
? ?}

? ?public MarqueeText(Context context, AttributeSet attrs) {
? ? ? ?super(context, attrs);
? ?}

? ?@Override
? ?public boolean isFocused(){
? ? ? ?return true;
? ?}
}


string.xml:

<resources>
? ?<string name="app_name">MarqueeTextViewDemon</string>
? ?<string name="Hello_world">我是一個TextView,我是一個長TextView。我是一個長TextView.</string>
</resources>

0 回復 有任何疑惑可以回復我~

singleline才能實現效果?? 雖然studio會提示過時? 但是依然可以用

用maxline反而會實現不了效果

0 回復 有任何疑惑可以回復我~
#1

深圳某男 提問者

singleline在studio不能使用,測試過了,別人和我說studio有一個專門的控件實現跑馬燈,不知道怎么搞
2017-05-31 回復 有任何疑惑可以回復我~

android studio

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Android攻城獅的第一門課(入門篇)
  • 參與學習       312492    人
  • 解答問題       4931    個

想快速掌握Android應用開發基礎,選擇學習這門課程就對了。

進入課程

搞了很久,還是無法實現跑馬燈效果,一行也實現不了。。。怎么搞,也無法定義singline,只能maxline

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號