/*这是activity*/package com.example.test;import android.app.Activity;import android.os.Bundle;import android.view.Menu;public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public boolean OnCreateOptionsMenu(Menu menu){ getMenuInflater().inflate(R.menu.main,menu); return true; }}/*这是方法的重写*/package com.example.test;import android.content.Context;import android.util.AttributeSet;import android.widget.TextView;public class GundongText extends TextView{ public GundongText(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public GundongText(Context context, AttributeSet attrs) { super(context, attrs); } public GundongText(Context context) { super(context); } @Override public boolean isFocused(){ return true; }}/*这是layout*/<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.test.MainActivity" tools:ignore="MergeRootFrame" > <com.exaple.test.GundongText android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:focusable="true" android:ellipsize="marquee" android:focusableInTouchMode="true" android:text="@string/Text" /> <com.exaple.test.GundongText android:layout_below="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="marquee" android:layout_marginTop="23dp" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" android:text="@string/Text" /></RelativeLayout>
添加回答
举报
0/150
提交
取消