Home > Mobile >  Multiple round button lined up, for advice
Multiple round button lined up, for advice

Time:11-18

Wanted to be an interface to do graphic button, each line, four row 7 lines, average each column in each row, as shown in figure 1, but now the circle line button will be stretched, as shown in figure 2
Great god guidance, can be in any size interface circular button, and the average alignment, spacing as
The enclosed code:


Main code:
Public class MainActivity extends AppCompatActivity {

Private static String [] irButtonName={
"CH1 and CH2," "ON", "LOCK", "10", "50", "OFF", "AUTO", "100", "300", "SENS +", "TEST", "500",
"1000", "SENS SemiAuto", ""," 2000 ", "24 h", "EYE", "PULSE", "30 s", "1 m", "3 m", "5 m",
"10 m, 20 m", "30 m", "60 m
"};
Private LinearLayout contentView.//declare a reference layout file
Private View. An OnClickListener btnOnClick;//declare the button to monitor reference
@ Override
Protected void onCreate (Bundle savedInstanceState) {
Super. OnCreate (savedInstanceState);
The setContentView (R.l ayout. Content_main);
ContentView=(LinearLayout) the findViewById (R.i, dc ontentView);
Enclosing initView (contentView);
}
Public void initView (LinearLayout parentLL) {
//LinearLayout parentLL=(LinearLayout) contentView;
Int size=irButtonName. Length;
LinearLayout. LayoutParams LayoutParams=new LinearLayout. LayoutParams (LinearLayout. LayoutParams. WRAP_CONTENT,
LinearLayout. LayoutParams. WRAP_CONTENT);//each row of the parameters of the horizontal LinearLayout

,23,10,23 layoutParams. The setMargins (10);
ArrayList

Content_main. XML code is as follows:

<? The XML version="1.0" encoding="utf-8"? & gt;
XMLNS: android="http://schemas.android.com/apk/res/android"
The android: id="@ + id/contentView"
Android: layout_width="match_parent"
Android: layout_height="match_parent"
Android: background="# FFFFFF"
Android: orientation="vertical" & gt;


CodePudding user response:

You have to calculate dynamic width, and then let the height=width of each button

CodePudding user response:

reference 1/f, just for funny reply:
you have to dynamically calculate width, and then let the height=width of each button


Height=width, a language points to wake, thank you very much

CodePudding user response:

Why not use Recyclerview directly, easy and convenient

CodePudding user response:

Draw a circle is used as the background, and then use the GridView or Recyclerview can be
  • Related