How to auto adjust font size in the action bar spinner based on orientation?

后端 未结 2 577
南笙
南笙 2020-12-10 19:16

I wanted to place a spinner in the action bar, just like in the Gmail app. So I created the following layout.

  

        
2条回答
  •  臣服心动
    2020-12-10 19:30

    They best way is to know the orientation of the device when the activity is started and use a layout depending on it.

    If portrait setContentView(R.layout.layout_with_bigfont);

    If lanscape setContentView(R.layout.layout_with_smallfont);

    otherwise you need to set the font for that View (in this case TextView) alone dynamically using setTextSize(xdp) instead of using 2 different layouts for different orientations

提交回复
热议问题