EX03_03.java package irdc.ex03_03;
import android.app.Activity; import android.content.res.Resources; import android.widget.TextView; import android.os.Bundle; import android.graphics.Color; import android.graphics.drawable.Drawable;
public class EX03_03 extends Activity{ private TextView mTextView01; private TextView mTextView02; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mTextView01=(TextView) findViewById(R.id.myTextView01); mTextView01.setText("我是应用Drawable背景色的戴维文本。"); Resources resources=getBaseContext().getResources(); Drawable HippoDrawable=resources.getDrawable(R.drawable.white); mTextView01.setBackgroundDrawable(HippoDrawable); mTextView02=(TextView) findViewById(R.id.myTextView02); mTextView02.setTextColor(Color.MAGENTA);//设置文本颜色 } }
main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/myTextView01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <TextView android:id="@+id/myTextView02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/world" /> </LinearLayout>
color.xml <?xml version="1.0" encoding="utf-8"?> <resources> <drawable name="darkgray">#404040ff</drawable> <drawable name="black">#000</drawable> <drawable name="red">#ff00ff</drawable> <drawable name="green">#0ff0ff</drawable> <drawable name="lightgray">#c0c0c0ff</drawable> <drawable name="white">#ffffffff</drawable> <drawable name="yellow">#ffFF33ff</drawable> <drawable name="blue">#00ffff</drawable> <drawable name="gray">#808080ff</drawable> <drawable name="magenta">#ff6699ff</drawable> <drawable name="cyan">#66ffffff</drawable> </resources>
strings.xml <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, aa!</string> <string name="app_name">ExampleTest</string> <string name="world">Hello World, aa!</string> </resources>
AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="irdc.ex03_03" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".EX03_03" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
</application> </manifest>

更多相关文章

  1. [Android]Android 颜色大全 colors.xml
  2. android实现文本信息复制,剪切板(ClipboardManager)
  3. android 开发技巧(8)--格式化 TextView 的文本
  4. 修改android statusbar颜色
  5. android TextView多行文本(超过3行)使用ellipsize属性无效问题的
  6. Android中字体颜色的设置
  7. Android知识点记录: 使用代码设置 android 上listView的条目的点
  8. android 字符串、颜色和尺寸

随机推荐

  1. android 7.0 使用apktool反编译apk
  2. 基于Android的短信管理系统
  3. Android 1.5 自带的图标一览表
  4. Android ContextMenu上下文菜单
  5. Android那些“没用“知识(一)
  6. Android 定时到服务器取数据并刷新
  7. Android 面试:常见问题总结
  8. android时间控件DatePicker使用实例
  9. android 水平进度对话框
  10. Android解析XML之XmlPullParser