为啥我把TextView换成com.immo.marqueetextview.MarqeeText之后布局全部变黑了。。。
为啥我把TextView换成com.immo.marqueetextview.MarqeeText之后布局全部变黑了。。。
为啥我把TextView换成com.immo.marqueetextview.MarqeeText之后布局全部变黑了。。。
2017-03-13
//新定义的类
package com.immo.marqueetextview;
import android.content.Context;
import android.util.AttributeSet;
import android.view.TextureView;
public class MarqeeText extends TextureView{
public MarqeeText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public MarqeeText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public MarqeeText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
public boolean isFocused() {
// TODO Auto-generated method stub
return true;
}
}
//xml
<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=".MainActivity"
tools:ignore="MergeRootFrame" >
<com.immo.marqueetextview.MarqeeText
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/TextView" />
<com.immo.marqueetextview.MarqeeText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:singleLine="true"
android:text="@string/TextView" />
</RelativeLayout>
//main
package com.immo.marqueetextview;
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);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
举报