Android 開發筆記___textvieww__跑馬燈效果

來源:互聯網
上載者:User

標籤:java   eth   into   bundle   恢複   cte   err   gravity   範圍   

 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3     android:orientation="vertical" android:layout_width="match_parent" 4     android:layout_height="match_parent"> 5  6     <TextView 7         android:layout_width="wrap_content" 8         android:layout_height="wrap_content" 9         android:text="示範效果"10         android:textColor="@color/text_color"11         android:textSize="25sp"12         android:layout_gravity="center"/>13 14     <LinearLayout15         android:layout_width="match_parent"16         android:orientation="vertical"17         android:layout_height="250dp">18 19         <TextView20             android:layout_width="match_parent"21             android:layout_height="wrap_content"22             android:layout_marginTop="20dp"23             android:gravity="center"24             android:text="跑馬燈效果,點擊暫停,再點擊恢複"/>25 26         <TextView27             android:layout_width="match_parent"28             android:layout_height="wrap_content"29             android:id="@+id/tv_marquee"30             android:layout_marginTop="20dp"31             android:singleLine="true"32             android:ellipsize="marquee"33             android:focusable="true"34             android:focusableInTouchMode="true"35             android:textColor="#000000"36             android:textSize="17sp"37             android:text="快訊:紅色預警,超高溫度即將到來,請吐魯番居民關緊門窗、備足糧草,開啟空調,做好防汛救災準備!"/>38 39         <Button40             android:layout_width="wrap_content"41             android:layout_height="wrap_content"42             android:text="聊天室效果"43             android:layout_marginTop="10dp"44             android:id="@+id/btn_liaotianshi"/>45 46     </LinearLayout>47 48     <TextView49         android:layout_width="wrap_content"50         android:layout_height="wrap_content"51         android:text="主要內容"52         android:textColor="@color/text_color"53         android:textSize="25sp"54         android:layout_gravity="center"/>55 56     <ScrollView57         android:layout_width="match_parent"58         android:layout_height="wrap_content">59 60         <TextView61             android:textColor="@color/text_color"62             android:text="1.跑馬燈效果\n首先設定為單行(singleline),再設定超出範圍後的省略方式(有三種:1、start  2、middle  3、end ,當設定為marquee時就是跑馬燈效果)。還需要擷取焦點,設定focusable=true,focusableInTouchMode=true\n\n2、聊天室效果\nscrollbars是vertical,在代碼中設定set movementmethod"63             android:layout_width="wrap_content"64             android:layout_height="wrap_content" />65 66     </ScrollView>67 68 </LinearLayout>

java

 1 package com.example.alimjan.hello_world; 2  3 import android.app.Activity; 4 import android.content.Context; 5 import android.content.Intent; 6 import android.os.Bundle; 7 import android.support.annotation.Nullable; 8 import android.view.View; 9 import android.widget.Button;10 11 /**12  * Created by alimjan on 6/30/2017.13  */14 15 public class class__2_3_1 extends Activity {16     private Button lts;17     @Override18     protected void onCreate(@Nullable Bundle savedInstanceState) {19         super.onCreate(savedInstanceState);20         setContentView(R.layout.code_2_3_1);21 22         lts = (Button) findViewById(R.id.btn_liaotianshi);23 24         lts.setOnClickListener(new View.OnClickListener() {25             @Override26             public void onClick(View v) {27                 Intent intent = new Intent(class__2_3_1.this, class__2_3_1_2.class);28                 class__2_3_1.this.startActivity(intent);29             }30         });31 32     }33 34     public static void startHome(Context mContext) {35         Intent intent = new Intent(mContext, class__2_3_1.class);36         mContext.startActivity(intent);37     }38 }

 

Android 開發筆記___textvieww__跑馬燈效果

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.