0
這裏是波紋管代碼,並希望通過使用放大和縮小按鈕形式的android進行放大和縮小設施。如何通過增加** android **中的佈局或textView文本大小來放大/縮小?
public class ShowDescription extends Activity{
@Override
public void onCreate(Bundle savedInstanceState){
new LoadDetails(this).execute();
super.onCreate(savedInstanceState);
setContentView(R.layout.showdescription);
String theStory = null;
String pubDate = null;
String storyTitle = null;
String writer = null;
//String test = null;
Intent intent = getIntent();
if (intent != null) {
Bundle b = intent.getExtras();
if (b == null) {
theStory = "bad bundle?";
} else {
storyTitle =ComplexScript.UTF2ANSI(ComplexScript.swap(b.getString("title")))+"\n\n";
//pubDate=ComplexScript.UTF2ANSI(ComplexScript.swap(ComplexScript.Replace(b.getString("pubdate"))))+ "\n\n";
pubDate=ComplexScript.Replace(b.getString("pubdate"))+"\n";
writer=ComplexScript.UTF2ANSI(ComplexScript.swap(b.getString("writers")))+",\n"+ComplexScript.UTF2ANSI(ComplexScript.swap(b.getString("initial")))+"\n";
theStory =ComplexScript.UTF2ANSI(ComplexScript.swap(b.getString("description"))).replace('\n', ' ').replaceAll(" "," ").replaceAll("‘","Ô").replaceAll("’","Õ");
//+ "\n\nMore information:\n" + b.getString("link");
//test=b.getString("image");
}
} else {
theStory = "Information not found.";
}
//Bitmap bimage= getBitmapFromURL(test);
//iv.setImageBitmap(bimage);
Typeface tf = Typeface.createFromAsset(getAssets(),
"font/SutonnyMJ.ttf");
TextView story = (TextView)findViewById(R.id.storybox);
story.setText(Html.fromHtml("<h1><font color='#B10000'>"+storyTitle+"</font></h1><small>"+pubDate+"<br/>"+writer+"</small><p>"+theStory+"</p>"));
story.setTypeface(tf);
story.setLineSpacing(1,(float) 1.5);
TextView moto =(TextView)findViewById(R.id.moto);
moto.setText("msev` we‡bv`b mviv¶Y");
moto.setTypeface(tf);
Button backButton = (Button)findViewById(R.id.back);
backButton.setTypeface(tf);
TextView tv = (TextView) findViewById(R.id.footer);
tv.setTypeface(tf);
backButton.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
finish();
}
});
}}
在這裏,下面是XML文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFF" android:orientation="vertical">
<ImageView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#86878A"
android:contentDescription="@string/app_name"
android:src="@drawable/logobn24"/>
<TextView android:id="@+id/moto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#86878A"
android:textColor="#FFF"
android:gravity="center"/>
<TextView android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#86878A"/>
<ScrollView android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFF"
android:orientation="vertical" >
<!-- android:textColor="#4e4e4e" -->
<ImageView android:id="@+id/img"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/des"/>
<TextView android:id="@+id/storybox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/img"
android:background="#FFFFFF"
android:paddingLeft="10dp"
android:textColor="#000"
android:textSize="18dp"
android:paddingTop="10dp"/>
</RelativeLayout>
</ScrollView>
<Button android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/back"/>
<TextView android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#86878A"
android:gravity="center_vertical|center_horizontal"
android:text="@string/footer"
android:textColor="#FFF" android:lineSpacingMultiplier="1.3"/>
任何一個可以使在放大和縮小乳房設施這個類?或者只是增加或減少文本視圖的文字大小故事? 任何人都可以幫助我嗎?
沒有發生。因爲我在我的模擬器中使用了android 2.2和API level 8。 – HeLLBoY 2012-03-08 05:53:12