how to change textsize in textView by clicking on button

how to change textsize in textView by clicking on button

By : user2950915
Date : November 17 2020, 11:58 AM
fixed the issue. Will look into that further According to the documentation, getTextSize() returns the text size in pixels, not sp as you are defining it.
code :
tvAdminPosts.setTextSize(TypedValue.COMPLEX_UNIT_PX, yourSizeValue);

Share : facebook icon twitter icon
how to change textsize of a textView on button Click?

how to change textsize of a textView on button Click?

By : Stevenson
Date : March 29 2020, 07:55 AM
this will help In your onClick method, you are inflating R.layout.MyLayout but you are not attaching it to a visible parent. So your TextView is not actually visible anywhere. Instead of inflating the layout, call findViewById on the view containing your TextView.
Change textsize of textview with button

Change textsize of textview with button

By : user2090611
Date : March 29 2020, 07:55 AM
I wish this help you The text size can changed at run time of course. You issue is related to the method changeTextViewTextSize. Using the inflater you are creating a new instance of R.layout.details, and through it, you are looking for the TextView you want to change the text size. But that layout is not at screen. It is not what you are seeing.
App Crash When Trying to Change textsize in textView by clicking on button

App Crash When Trying to Change textsize in textView by clicking on button

By : Anil Kemisetti
Date : March 29 2020, 07:55 AM
wish of those help Display the new layout in the form of a DialogFragment. The idea is to show the increase/Decrease option in the form of a DialogFragment popup. you can increase/decrease size from the popup. Once the popup dismisses the selected size is set to the TextView in your Activity.
code :
public class MainActivity extends AppCompatActivity {

public static int updatedSize;
TextView greetingText;

protected void onCreate(Bundle savedInstanceState) {
    greetingText = (TextView)findViewById(R.id.hello_world_text);

public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;

public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;

    return super.onOptionsItemSelected(item);

public void mycustomLayout(){
    FragmentManager manager = getFragmentManager();
    PopUp popUp = new PopUp(new FragmentDismissHandler());


public void refreshText(){
    if( updatedSize>0)

private class FragmentDismissHandler extends Handler {
    public void handleMessage(Message msg) {

public class PopUp extends DialogFragment implements View.OnClickListener{

ImageButton increase,decrease,set;
TextView sizeOfText;
static int size;
Handler handler;

public PopUp(Handler handler) {
    this.handler = handler;
public PopUp(){


public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    getDialog().setTitle("change text size");
    View view = inflater.inflate(R.layout.my_custom_layout, container, false);

    increase = (ImageButton)view.findViewById(R.id.inc);

    decrease = (ImageButton)view.findViewById(R.id.dec);

    sizeOfText = (TextView)view.findViewById(R.id.size_text);

    set = (ImageButton)view.findViewById(R.id.ok);

    size = (int) sizeOfText.getTextSize();

    return view;

public void onClick(View view) {
    int id= view.getId();

        size = size +1;
    if(id== R.id.dec){
        size = size - 1;
    if(id== R.id.ok){

public void onDismiss(DialogInterface dialog) {
    MainActivity.updatedSize = size;

Android How to change data of Textview by clicking on button

Android How to change data of Textview by clicking on button

Date : March 29 2020, 07:55 AM
wish helps you First of all, the app looks like this. , First make your textview final and them set it's value in onClick
How to change the color of a TextView in one activity by clicking a button in another?

How to change the color of a TextView in one activity by clicking a button in another?

By : VS Developer
Date : March 29 2020, 07:55 AM
Hope this helps You can save your color with Shared Preferences when your button is clicked and later get it :
In activity 2 when your button is pressed :
code :
        .putString(key, value).apply();
PreferenceManager.getDefaultSharedPreferences(DriverScreen.this).getString(key, "default value")
Related Posts Related Posts :
  • How to write generic Java API without method Overloading
  • Java Serialization / Deserialization of an ArrayList works only on first program execution
  • Conway's Game of Life's rules dont apply properly
  • call a java method when Click on a html button without using javascript
  • Why does SSLSocketFactory.createSocket returns a Socket instead of SSLSocket?
  • How to schedule a task in Tomcat
  • compare two pdf files (approach) using java
  • What is the use of allowCoreThreadTimeout( ) in ThreadPoolExecutor?
  • Describe the Strategy Design Pattern in Java?
  • MongoDB too many open connections
  • Issue with generate JAXB classes with value constructors
  • Moving from one frame to another in java swing
  • Get a thread by Id
  • how to open front camera and back camera at same time?
  • Messed up with Java Declaration
  • Extracting chart in EXcel as image using java
  • How to get latitude and longitude in Android phone?
  • Do GC pauses and kill -STOP produce the same behavior?
  • Android HTML.ImageGetter Images resized
  • The way to instantiate map<String, List<String>> in Java
  • Java Making objects move while buttons held
  • Androidx Navigation View - `setNavigationItemSelectedListener` Doesn't Work
  • after compiling code JFrame does not appear
  • Netbeans project, JFrames ran from the main JFrame close all JFrames in project
  • Square Retrofit Client: How to enable/disable followRedirects? How to intercept redirect URL?
  • Java Circular Reference - Can’t Compile
  • Mouse click on specific time JAVA
  • android 4 onCreateDialog return type incompatible when overriding
  • Java Implementation of Oracle's DBMS_UTILITY.GET_HASH_VALUE Function
  • javac cannot be run, and furthermore does not seem installed
  • Function to obtain a thread given its ID
  • Java File path to Executable has spaces
  • Minimum Oracle Java VM heap memory setting?
  • Elegant way to create one of a large number of classes
  • Java fx binding styles
  • Summing weights based on string in large file
  • Android ListView setOnItemClickListener not working
  • How is the Java Bootstrap Classloader loaded?
  • Check object is blank
  • Add image between text in JEditorPane
  • Java POI Excel creating new column and new rows
  • NullPointerException when managing bean with Spring+JSF(Primefaces)
  • Content autocomplete in spring tool suite 4
  • Super Noob Help ~ MouseEvent/Frame
  • Making one project with dependencies stand-alone in Eclipse (Java)
  • Jsoup- getting certain attributes from website
  • MongoDB, how to make a link between collections with JAVA code
  • Overriding an abstract method means class abstract class or not in java?
  • Bukkit teleport - nullPointerException
  • How to check if a Float variable is negative in java
  • Servlet: Cannot forward after response has been committed
  • sql query to select a specific cell in excel
  • How to make new picture when mouse dragged in java
  • Use Constants interface in GWT Project
  • Setting size of a JPanel in GroupLayout
  • Construct a map from two equal size arrays
  • Implementing Read-Write Locks with Double-Checked Locking
  • Disable NO_BUTTON from JOptionPane Java if a condition is true
  • UDP multiple socket
  • Android Threading: This Handler class should be static or leaks might occur
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org