بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
تغییر فونت کل برنامه؟
با سلام و عرض خسته نباشید
من یه سری کد تغییر فونت دارم که در اون با تغییر seekbar سایز text بالای اون تغییر میکنه.کد هارو د ر پایین قرار دادم.
کد های java:
package drikvand.soroush;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ScrollView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
public class AdvanceSetting extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.advance_setting);
final Button btnChangeVisibility = (Button) findViewById(R.id.btnChangeVisibility);
final ScrollView ScrollView = (ScrollView) findViewById(R.id.ScrollView);
ScrollView.setVisibility(View.GONE);
final SeekBar seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
Button btnSave = (Button) findViewById(R.id.save);
final TextView txtNemune = (TextView) findViewById(R.id.txtNemune);
int size = G.preferences.getInt("FONT_SIZE", 20);
int size1 = size - 20;
seekBar1.setProgress(size1);
txtNemune.setTextSize(size);
seekBar1.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int value = seekBar1.getProgress();
int value1 = value + 20;
txtNemune.setTextSize(value1);
}
});
btnSave.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
int value = seekBar1.getProgress();
int value1 = value + 20;
SharedPreferences.Editor editor = G.preferences.edit();
editor.putInt("FONT_SIZE", value1);
editor.commit();
}
});
btnChangeVisibility.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if (ScrollView.getVisibility() == View.GONE) {
ScrollView.setVisibility(View.VISIBLE);
} else {
ScrollView.setVisibility(View.GONE);
}
}
});
}
}
کد های 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:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/btnChangeVisibility"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/setting"
android:gravity="center" />
</LinearLayout>
<ScrollView
android:id="@+id/ScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/reletive1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="20" />
<Button
android:id="@+id/save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ذخیره" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtNemune"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:gravity="center"
android:text="سلام"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>
</LinearLayout>
کد های G.java:
package drikvand.soroush;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
public class G extends Application {
public static Context context;
public static SharedPreferences preferences;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
preferences = PreferenceManager.getDefaultSharedPreferences(context);
}
}
سوال:ولی من میخوام با تغییر seekbar سایز تمامی text های برنامه تغییر کنه؟؟
خودم هم یه سرچی در انجمن کردم تا به این رسیدم.
http://answers.uncocoder.com/question/2640/آموزش-تغییر-فونت-کل-برنامه
ولی نمیدونم که چطور باید بوسیله ی این دو کد سایز تمامی text های برنامه رو تغییر بدم؟
لطفا کمک کنید.
برای این سوال پاسخی وجود ندارد.
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .