TableLayout resizing views on resizing text even though it is fixed size










0














I have some square TextViews in a TableLayout. I have to resize text programmatically. Cannot use the new "auto-resize", I need to set the text size myself.



So, my approach is to have fixed layout_height and layout_width for the TextViews in the table layout and to use setTextSize in code.



Problem is as soon as text is resized, weird things start happening, and not just to the TextView/cell that is being edited, but the neighboring ones too!



The first time text is resized, the neighboring cell is affected (see image). This happens both on the real phone (API24) and emulator (API 24, 28). The second time text is resized, the second cell goes back to normal on the emulator. On the real device, the first cell is resized again, or the top margin increased.



layout problems



I tried changing different settings for TableLayout, TableRow, and TextView (wrap_content, min/max Height), but nothing fixes the issue except for commenting out the setTextSize.



I do need to use TableLayout, so replacing this with a different layout is not an option for me.



Why doesn't this work?



To replicate the issue paste below layout and code into a new "empty activity" project. I am using, at the time of writing, the latest software (Android Studio 3.2.1 with compile sdk version API 28, java version 1.8, min sdk version 22.



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="false"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainContainer">

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#000">

<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">

<TextView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFF"
android:textColor="#000"
android:id="@+id/textView1"
android:layout_margin="1dp"/>

<TextView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFF"
android:textColor="#000"
android:layout_margin="1dp"/>

</TableRow>

</TableLayout>


<Button
android:layout_gravity="bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click"
android:id="@+id/button1"/>

</LinearLayout>


My activity code is:



package app.howsmydriving.layoutproblem;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity


private String sContent = "";

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button button1 = findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
sContent += "A";
TextView tv = findViewById(R.id.textView1);
tv.setText(sContent);

if(sContent.length() < 3)
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 30);
else
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);



);














share|improve this question























  • can you try using TypedValue.COMPLEX_UNIT_SP instead of TypedValue.COMPLEX_UNIT_DIP
    – Karan Mer
    Nov 12 at 10:46










  • Doesn't fix it. I am starting to think it is a bug in table layout
    – under
    Nov 12 at 21:17















0














I have some square TextViews in a TableLayout. I have to resize text programmatically. Cannot use the new "auto-resize", I need to set the text size myself.



So, my approach is to have fixed layout_height and layout_width for the TextViews in the table layout and to use setTextSize in code.



Problem is as soon as text is resized, weird things start happening, and not just to the TextView/cell that is being edited, but the neighboring ones too!



The first time text is resized, the neighboring cell is affected (see image). This happens both on the real phone (API24) and emulator (API 24, 28). The second time text is resized, the second cell goes back to normal on the emulator. On the real device, the first cell is resized again, or the top margin increased.



layout problems



I tried changing different settings for TableLayout, TableRow, and TextView (wrap_content, min/max Height), but nothing fixes the issue except for commenting out the setTextSize.



I do need to use TableLayout, so replacing this with a different layout is not an option for me.



Why doesn't this work?



To replicate the issue paste below layout and code into a new "empty activity" project. I am using, at the time of writing, the latest software (Android Studio 3.2.1 with compile sdk version API 28, java version 1.8, min sdk version 22.



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="false"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainContainer">

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#000">

<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">

<TextView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFF"
android:textColor="#000"
android:id="@+id/textView1"
android:layout_margin="1dp"/>

<TextView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFF"
android:textColor="#000"
android:layout_margin="1dp"/>

</TableRow>

</TableLayout>


<Button
android:layout_gravity="bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click"
android:id="@+id/button1"/>

</LinearLayout>


My activity code is:



package app.howsmydriving.layoutproblem;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity


private String sContent = "";

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button button1 = findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
sContent += "A";
TextView tv = findViewById(R.id.textView1);
tv.setText(sContent);

if(sContent.length() < 3)
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 30);
else
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);



);














share|improve this question























  • can you try using TypedValue.COMPLEX_UNIT_SP instead of TypedValue.COMPLEX_UNIT_DIP
    – Karan Mer
    Nov 12 at 10:46










  • Doesn't fix it. I am starting to think it is a bug in table layout
    – under
    Nov 12 at 21:17













0












0








0







I have some square TextViews in a TableLayout. I have to resize text programmatically. Cannot use the new "auto-resize", I need to set the text size myself.



So, my approach is to have fixed layout_height and layout_width for the TextViews in the table layout and to use setTextSize in code.



Problem is as soon as text is resized, weird things start happening, and not just to the TextView/cell that is being edited, but the neighboring ones too!



The first time text is resized, the neighboring cell is affected (see image). This happens both on the real phone (API24) and emulator (API 24, 28). The second time text is resized, the second cell goes back to normal on the emulator. On the real device, the first cell is resized again, or the top margin increased.



layout problems



I tried changing different settings for TableLayout, TableRow, and TextView (wrap_content, min/max Height), but nothing fixes the issue except for commenting out the setTextSize.



I do need to use TableLayout, so replacing this with a different layout is not an option for me.



Why doesn't this work?



To replicate the issue paste below layout and code into a new "empty activity" project. I am using, at the time of writing, the latest software (Android Studio 3.2.1 with compile sdk version API 28, java version 1.8, min sdk version 22.



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="false"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainContainer">

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#000">

<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">

<TextView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFF"
android:textColor="#000"
android:id="@+id/textView1"
android:layout_margin="1dp"/>

<TextView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFF"
android:textColor="#000"
android:layout_margin="1dp"/>

</TableRow>

</TableLayout>


<Button
android:layout_gravity="bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click"
android:id="@+id/button1"/>

</LinearLayout>


My activity code is:



package app.howsmydriving.layoutproblem;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity


private String sContent = "";

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button button1 = findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
sContent += "A";
TextView tv = findViewById(R.id.textView1);
tv.setText(sContent);

if(sContent.length() < 3)
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 30);
else
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);



);














share|improve this question















I have some square TextViews in a TableLayout. I have to resize text programmatically. Cannot use the new "auto-resize", I need to set the text size myself.



So, my approach is to have fixed layout_height and layout_width for the TextViews in the table layout and to use setTextSize in code.



Problem is as soon as text is resized, weird things start happening, and not just to the TextView/cell that is being edited, but the neighboring ones too!



The first time text is resized, the neighboring cell is affected (see image). This happens both on the real phone (API24) and emulator (API 24, 28). The second time text is resized, the second cell goes back to normal on the emulator. On the real device, the first cell is resized again, or the top margin increased.



layout problems



I tried changing different settings for TableLayout, TableRow, and TextView (wrap_content, min/max Height), but nothing fixes the issue except for commenting out the setTextSize.



I do need to use TableLayout, so replacing this with a different layout is not an option for me.



Why doesn't this work?



To replicate the issue paste below layout and code into a new "empty activity" project. I am using, at the time of writing, the latest software (Android Studio 3.2.1 with compile sdk version API 28, java version 1.8, min sdk version 22.



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="false"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainContainer">

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#000">

<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">

<TextView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFF"
android:textColor="#000"
android:id="@+id/textView1"
android:layout_margin="1dp"/>

<TextView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#FFF"
android:textColor="#000"
android:layout_margin="1dp"/>

</TableRow>

</TableLayout>


<Button
android:layout_gravity="bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click"
android:id="@+id/button1"/>

</LinearLayout>


My activity code is:



package app.howsmydriving.layoutproblem;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity


private String sContent = "";

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button button1 = findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
sContent += "A";
TextView tv = findViewById(R.id.textView1);
tv.setText(sContent);

if(sContent.length() < 3)
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 30);
else
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);



);











java android android-layout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 21:23

























asked Nov 12 at 10:03









under

863418




863418











  • can you try using TypedValue.COMPLEX_UNIT_SP instead of TypedValue.COMPLEX_UNIT_DIP
    – Karan Mer
    Nov 12 at 10:46










  • Doesn't fix it. I am starting to think it is a bug in table layout
    – under
    Nov 12 at 21:17
















  • can you try using TypedValue.COMPLEX_UNIT_SP instead of TypedValue.COMPLEX_UNIT_DIP
    – Karan Mer
    Nov 12 at 10:46










  • Doesn't fix it. I am starting to think it is a bug in table layout
    – under
    Nov 12 at 21:17















can you try using TypedValue.COMPLEX_UNIT_SP instead of TypedValue.COMPLEX_UNIT_DIP
– Karan Mer
Nov 12 at 10:46




can you try using TypedValue.COMPLEX_UNIT_SP instead of TypedValue.COMPLEX_UNIT_DIP
– Karan Mer
Nov 12 at 10:46












Doesn't fix it. I am starting to think it is a bug in table layout
– under
Nov 12 at 21:17




Doesn't fix it. I am starting to think it is a bug in table layout
– under
Nov 12 at 21:17












2 Answers
2






active

oldest

votes


















2














First thing to understand is what android:baselineAligned actually means.



This attribute is set to true by default, and controls the vertical positioning of sibling TextViews inside a horizontal LinearLayout. The TextViews will be pushed up or down as necessary to make sure that all text baselines (the imaginary line the text is sitting on) line up.



enter image description here



The next thing to realize is that TableRow is a subclass of LinearLayout, and is horizontal.



So, if you want full control over the vertical positioning of the TextViews inside your TableRow, you should set android:baselineAligned="false" to avoid having the system override you.



enter image description here



Edit



The dimensions of the TextView have no effect on baseline alignment; the LinearLayout will both (a) move the TextViews themselves up and down as necessary and (b) move the text within the TextView up and down as necessary to make sure that the baselines align.



Here's a demo. I've set background colors to make everything very obvious. The parent LinearLayout has a fixed height of 100dp, the first TextView is wrap_content, the second is 40dp (bigger than it needs to be), and the third is 16dp (smaller than it needs to be).



enter image description here



This is all in service of making sure that the baselines line up. The LinearLayout will do whatever it needs to to make this happen, unless you disable baseline alignment.






share|improve this answer






















  • That would make sense if textView was set to wrap_content, but when the textView height is fixed this should not happen. While troubleshooting, I was looking at top margin and layout height values and they were not changing. I did notice padding value changing from -10 to -6. Seems that text size affects padding when baseline align is ON which looks like a bug to me.
    – under
    Nov 13 at 1:16











  • @under see my edit. TextView dimensions have no effect on baseline alignment.
    – Ben P.
    Nov 13 at 3:50


















0














I managed to fix it by switching off baselineAligned for LinearLayout, TableLayout and TableRow:



android:baselineAligned="false"


Not sure why this works, if someone has a better explanation I will accept that as an answer.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259820%2ftablelayout-resizing-views-on-resizing-text-even-though-it-is-fixed-size%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    First thing to understand is what android:baselineAligned actually means.



    This attribute is set to true by default, and controls the vertical positioning of sibling TextViews inside a horizontal LinearLayout. The TextViews will be pushed up or down as necessary to make sure that all text baselines (the imaginary line the text is sitting on) line up.



    enter image description here



    The next thing to realize is that TableRow is a subclass of LinearLayout, and is horizontal.



    So, if you want full control over the vertical positioning of the TextViews inside your TableRow, you should set android:baselineAligned="false" to avoid having the system override you.



    enter image description here



    Edit



    The dimensions of the TextView have no effect on baseline alignment; the LinearLayout will both (a) move the TextViews themselves up and down as necessary and (b) move the text within the TextView up and down as necessary to make sure that the baselines align.



    Here's a demo. I've set background colors to make everything very obvious. The parent LinearLayout has a fixed height of 100dp, the first TextView is wrap_content, the second is 40dp (bigger than it needs to be), and the third is 16dp (smaller than it needs to be).



    enter image description here



    This is all in service of making sure that the baselines line up. The LinearLayout will do whatever it needs to to make this happen, unless you disable baseline alignment.






    share|improve this answer






















    • That would make sense if textView was set to wrap_content, but when the textView height is fixed this should not happen. While troubleshooting, I was looking at top margin and layout height values and they were not changing. I did notice padding value changing from -10 to -6. Seems that text size affects padding when baseline align is ON which looks like a bug to me.
      – under
      Nov 13 at 1:16











    • @under see my edit. TextView dimensions have no effect on baseline alignment.
      – Ben P.
      Nov 13 at 3:50















    2














    First thing to understand is what android:baselineAligned actually means.



    This attribute is set to true by default, and controls the vertical positioning of sibling TextViews inside a horizontal LinearLayout. The TextViews will be pushed up or down as necessary to make sure that all text baselines (the imaginary line the text is sitting on) line up.



    enter image description here



    The next thing to realize is that TableRow is a subclass of LinearLayout, and is horizontal.



    So, if you want full control over the vertical positioning of the TextViews inside your TableRow, you should set android:baselineAligned="false" to avoid having the system override you.



    enter image description here



    Edit



    The dimensions of the TextView have no effect on baseline alignment; the LinearLayout will both (a) move the TextViews themselves up and down as necessary and (b) move the text within the TextView up and down as necessary to make sure that the baselines align.



    Here's a demo. I've set background colors to make everything very obvious. The parent LinearLayout has a fixed height of 100dp, the first TextView is wrap_content, the second is 40dp (bigger than it needs to be), and the third is 16dp (smaller than it needs to be).



    enter image description here



    This is all in service of making sure that the baselines line up. The LinearLayout will do whatever it needs to to make this happen, unless you disable baseline alignment.






    share|improve this answer






















    • That would make sense if textView was set to wrap_content, but when the textView height is fixed this should not happen. While troubleshooting, I was looking at top margin and layout height values and they were not changing. I did notice padding value changing from -10 to -6. Seems that text size affects padding when baseline align is ON which looks like a bug to me.
      – under
      Nov 13 at 1:16











    • @under see my edit. TextView dimensions have no effect on baseline alignment.
      – Ben P.
      Nov 13 at 3:50













    2












    2








    2






    First thing to understand is what android:baselineAligned actually means.



    This attribute is set to true by default, and controls the vertical positioning of sibling TextViews inside a horizontal LinearLayout. The TextViews will be pushed up or down as necessary to make sure that all text baselines (the imaginary line the text is sitting on) line up.



    enter image description here



    The next thing to realize is that TableRow is a subclass of LinearLayout, and is horizontal.



    So, if you want full control over the vertical positioning of the TextViews inside your TableRow, you should set android:baselineAligned="false" to avoid having the system override you.



    enter image description here



    Edit



    The dimensions of the TextView have no effect on baseline alignment; the LinearLayout will both (a) move the TextViews themselves up and down as necessary and (b) move the text within the TextView up and down as necessary to make sure that the baselines align.



    Here's a demo. I've set background colors to make everything very obvious. The parent LinearLayout has a fixed height of 100dp, the first TextView is wrap_content, the second is 40dp (bigger than it needs to be), and the third is 16dp (smaller than it needs to be).



    enter image description here



    This is all in service of making sure that the baselines line up. The LinearLayout will do whatever it needs to to make this happen, unless you disable baseline alignment.






    share|improve this answer














    First thing to understand is what android:baselineAligned actually means.



    This attribute is set to true by default, and controls the vertical positioning of sibling TextViews inside a horizontal LinearLayout. The TextViews will be pushed up or down as necessary to make sure that all text baselines (the imaginary line the text is sitting on) line up.



    enter image description here



    The next thing to realize is that TableRow is a subclass of LinearLayout, and is horizontal.



    So, if you want full control over the vertical positioning of the TextViews inside your TableRow, you should set android:baselineAligned="false" to avoid having the system override you.



    enter image description here



    Edit



    The dimensions of the TextView have no effect on baseline alignment; the LinearLayout will both (a) move the TextViews themselves up and down as necessary and (b) move the text within the TextView up and down as necessary to make sure that the baselines align.



    Here's a demo. I've set background colors to make everything very obvious. The parent LinearLayout has a fixed height of 100dp, the first TextView is wrap_content, the second is 40dp (bigger than it needs to be), and the third is 16dp (smaller than it needs to be).



    enter image description here



    This is all in service of making sure that the baselines line up. The LinearLayout will do whatever it needs to to make this happen, unless you disable baseline alignment.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 13 at 3:50

























    answered Nov 13 at 0:59









    Ben P.

    22.3k31846




    22.3k31846











    • That would make sense if textView was set to wrap_content, but when the textView height is fixed this should not happen. While troubleshooting, I was looking at top margin and layout height values and they were not changing. I did notice padding value changing from -10 to -6. Seems that text size affects padding when baseline align is ON which looks like a bug to me.
      – under
      Nov 13 at 1:16











    • @under see my edit. TextView dimensions have no effect on baseline alignment.
      – Ben P.
      Nov 13 at 3:50
















    • That would make sense if textView was set to wrap_content, but when the textView height is fixed this should not happen. While troubleshooting, I was looking at top margin and layout height values and they were not changing. I did notice padding value changing from -10 to -6. Seems that text size affects padding when baseline align is ON which looks like a bug to me.
      – under
      Nov 13 at 1:16











    • @under see my edit. TextView dimensions have no effect on baseline alignment.
      – Ben P.
      Nov 13 at 3:50















    That would make sense if textView was set to wrap_content, but when the textView height is fixed this should not happen. While troubleshooting, I was looking at top margin and layout height values and they were not changing. I did notice padding value changing from -10 to -6. Seems that text size affects padding when baseline align is ON which looks like a bug to me.
    – under
    Nov 13 at 1:16





    That would make sense if textView was set to wrap_content, but when the textView height is fixed this should not happen. While troubleshooting, I was looking at top margin and layout height values and they were not changing. I did notice padding value changing from -10 to -6. Seems that text size affects padding when baseline align is ON which looks like a bug to me.
    – under
    Nov 13 at 1:16













    @under see my edit. TextView dimensions have no effect on baseline alignment.
    – Ben P.
    Nov 13 at 3:50




    @under see my edit. TextView dimensions have no effect on baseline alignment.
    – Ben P.
    Nov 13 at 3:50













    0














    I managed to fix it by switching off baselineAligned for LinearLayout, TableLayout and TableRow:



    android:baselineAligned="false"


    Not sure why this works, if someone has a better explanation I will accept that as an answer.






    share|improve this answer

























      0














      I managed to fix it by switching off baselineAligned for LinearLayout, TableLayout and TableRow:



      android:baselineAligned="false"


      Not sure why this works, if someone has a better explanation I will accept that as an answer.






      share|improve this answer























        0












        0








        0






        I managed to fix it by switching off baselineAligned for LinearLayout, TableLayout and TableRow:



        android:baselineAligned="false"


        Not sure why this works, if someone has a better explanation I will accept that as an answer.






        share|improve this answer












        I managed to fix it by switching off baselineAligned for LinearLayout, TableLayout and TableRow:



        android:baselineAligned="false"


        Not sure why this works, if someone has a better explanation I will accept that as an answer.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 at 0:29









        under

        863418




        863418



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259820%2ftablelayout-resizing-views-on-resizing-text-even-though-it-is-fixed-size%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto