Android studio-learning-012-Java-set button width

tags: Android

Android studio-learning-012-Java-set button width-2020-4-18

<Button
android:id="@+id/btn"
android:layout_width="10dp"
android:layout_height="90dp"
android:background="#000000"
android:paddingTop="0dp"
android:text="Button"
android:textSize="15dp"></Button>
public Button btn;
btn = (Button) findViewById(R.id.btn);
LinearLayout.LayoutParams params = 
new LinearLayout.LayoutParams(264, LinearLayout.LayoutParams.WRAP_CONTENT);
//264 is the width
btn.setLayoutParams(params);

Intelligent Recommendation

Solve Android Studio button background color unable to set

Solution: Lower RES / VALUES / THEMES.XML Change to That is to add a Bridge in the last side. forward from: https://www.cnblogs.com/linmob/p/14277303.html...

Android Development Learning - Android Studio-09- radio button, checkbox

Write a directory title here single button Check box single button As the name suggests, the only place to pay attention is to be a problem with multiple options Radiobutton to add in a radiogroup, an...

Android Studio button Button operation

Features Buttons are too common, login button, register button, submit button, cancel button. Buttons are used in almost all programs. Show button effect: Button click event After the button is clicke...

Android Studio 4.0.1 Java development of Android applications 3: Button

Same as last time, first write a line of code and put the Button in the last LinearLayout Take a look at the commonly used functions in Button. Like TextView, it contains 4 constructors. We only need ...

Android Studio Button beautification

Change the corner, fill color, and border color of the button's Button control. Steps: Create a new btn_all_shape.xml in res>drawable : Add this sentence to the xml of the button to be changed:...

More Recommendation

Android studio picture button

The .xml file code is as follows: The java file code is as follows: Don't explain too much here, similar to the normal button, you can see the Android studio ordinary button....

Android Studio Control Button

Add the following code in Activity_Main.xml: MainActivity.java China code is as follows: operation result:...

Get screen width in Android Studio

How to get the width of the entire screen...

Android Get button Button height Width Coordinate

                When the button is initially, the height, width, and coordinate values ​​are not obtained. It needs to be obt...

The secret behind the Android Studio 'Run' button (Grade learning [1])

  The 'Run' button, at a point, Android Studio is started, the code miracle turns into an APK, is installed on the phone, display the interface of the app. What happened behind? Click the RUN but...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top