android - No changes being applied to my Activity -


i trying test if of these approaches work, don't seem changing anything. code in question below.

public class matching extends appcompatactivity{  button button1;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     this.requestwindowfeature(window.feature_no_title);     setcontentview(r.layout.activity_flipmodule);      button1 = (button) findviewbyid(r.id.button1);      displaymetrics displaymetrics = new displaymetrics();     getwindowmanager().getdefaultdisplay().getmetrics(displaymetrics);     final int height = displaymetrics.heightpixels;     final int width = displaymetrics.widthpixels;      button1.setheight((int)(height*.3));     button1.setwidth((int)(width*.3));      button1.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {          }     }); } } 

first off, wanted rid of bar across top of screen says name of activity class being called from, used line this.requestwindowfeature(window.feature_no_title); before set content view, doesn't seem anything.

also, getting extremely frustrated trying xml buttons scale screen (which still don't think possible through xml, correct me if wrong). decided in oncreate intent. got width , height reason when tried adjust width , height via setheight , setwidth, doesn't change button size.

what simple thing overlooking these 2 problems? appreciated, thanks.

edit:

my plan here add buttons table , resize them later, sorry bit sloppy table rows in there

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">  <linearlayout     android:layout_width="match_parent"     android:layout_height="55dp"     android:orientation="horizontal"> </linearlayout>  <tablelayout     android:layout_width="match_parent"     android:layout_height="match_parent">      <tablerow         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_margin="10dp">          <button             android:id="@+id/button1"             android:layout_width="@dimen/box_size"             android:layout_height="@dimen/box_size"             android:text="button" />      </tablerow>      <tablerow         android:layout_width="match_parent"         android:layout_height="match_parent" />      <tablerow         android:layout_width="match_parent"         android:layout_height="match_parent" />      <tablerow         android:layout_width="match_parent"         android:layout_height="match_parent" /> </tablelayout> </linearlayout> 

update

to remove title bar across top of screen, make sure activity's theme has these:

    <item name="windowactionbar">false</item>     <item name="windownotitle">true</item> 

original

to make buttons scale screen size, can use constraintlayout. add guidelines @ 33% , 67% , position buttons relative them. here's example 1 button:

<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.constraint.guideline         android:id="@+id/leftrail"         android:layout_width="0dp"         android:layout_height="0dp"         android:orientation="vertical"         app:layout_constraintguide_percent="0.33"/>      <android.support.constraint.guideline         android:id="@+id/rightrail"         android:layout_width="0dp"         android:layout_height="0dp"         android:orientation="vertical"         app:layout_constraintguide_percent="0.67"/>      <android.support.constraint.guideline         android:id="@+id/toprail"         android:layout_width="0dp"         android:layout_height="0dp"         android:orientation="horizontal"         app:layout_constraintguide_percent="0.33"/>      <android.support.constraint.guideline         android:id="@+id/bottomrail"         android:layout_width="0dp"         android:layout_height="0dp"         android:orientation="horizontal"         app:layout_constraintguide_percent="0.67"/>      <button         android:layout_width="0dp"         android:layout_height="0dp"         android:text="scales screen size"         app:layout_constrainttop_totopof="@id/toprail"         app:layout_constraintleft_toleftof="@id/leftrail"         app:layout_constraintright_torightof="@id/rightrail"         app:layout_constraintbottom_tobottomof="@id/bottomrail"/>   </android.support.constraint.constraintlayout> 

enter image description here


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -