效果展示,嗷嗚~~
下面展示 XML碼片
。
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="實現最簡單走馬燈"
android:textSize="28sp"
android:layout_gravity="center"
android:drawablePadding="4dp"
/>
<TextView android:layout_marginTop="20dp"
android:id="@+id/tv3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="山有木兮木有枝,心悅君兮君不知! 山有木兮木有枝,心悅君兮君不知!"
android:textColor="#0000ff"
android:textSize="20dp"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
/>
<TextView android:layout_marginTop="20dp"
android:id="@+id/tv2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="古詩"
android:textSize="20dp"
android:gravity="right"
android:shadowColor="#0000ff"
android:shadowRadius="3"
android:shadowDx="15"
android:shadowDy="15"
/>
<TextView
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" 天涯也有江南信,梅破知春近。夜闌風細得香遲,不道曉來開遍向南枝。"
android:textSize="20sp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" 玉臺弄粉花應妒,飄到眉心住。平生個裏願懷深,去國十年老盡少年心。"
android:textSize="20sp"
/>
以及JAVA代碼
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.introduction_layout);
TextView tv3=findViewById(R.id.tv3);
tv3.setSelected(true);
TextView tv1=(TextView)findViewById(R.id.tv1);
Drawable drawable=getResources().getDrawable(R.drawable.tou11);
drawable.setBounds(0,0,130,130);
tv1.setCompoundDrawables(drawable,null,null,null);
}