public class ClickUI { private static int Width=1; private static int pop=(int) (local.W()*0.2); private static Tpopup Combot; private static Tpopup Movement; private static Tpopup World; private static TView mainll; public static void show(Context context){ Combot = ClickPopupwindow(context).gravity(mainll, "LC",50, 0); Movement = ClickPopupwindow(context).gravity(mainll, "LC",50+pop*Width, 0); World=ClickPopupwindow(context).gravity(mainll, "LC",50+pop*Width, 0); //ClickPopupwindow(context); //ClickPopupwindow(context); } public static Tpopup ClickPopupwindow(Context context){ mainll = new TView(context).setBgD("#ffffff", 90, "TB", 0).WH((int) (local.W() * 0.2), (int) (local.H() * 0.8)).gravity("RC").ori(1); TView mainll2 = new TView(context).setnullc("#ffffff", 50, "TB", 0).WH((int) (local.W() * 0.2), (int) (local.H() * 0.8)).gravity("RC").ori(1); Tpopup main = new Tpopup().WH(LinearLayout.LayoutParams.WRAP_CONTENT, (int) (local.H() * 0.85)).SC(true).SO(false).SF(false).ST(true).Anim("Di"); mainll.addView(mainll2); Width = Width + 1; return main; } }此代码显示出来的popupwindow无法从左到右依次排序且间隔为50,请帮我修改它变成popupwindow从左到右间隔为50
时间: 2024-03-10 10:49:48 浏览: 77
JS中的public和private对象,即static修饰符
可以尝试使用LinearLayout来实现从左到右依次排序的效果,代码如下:
```
public class ClickUI {
private static int pop = (int) (local.W() * 0.2);
private static Tpopup Combot;
private static Tpopup Movement;
private static Tpopup World;
private static LinearLayout mainll;
public static void show(Context context) {
mainll = new LinearLayout(context);
mainll.setOrientation(LinearLayout.HORIZONTAL);
mainll.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
mainll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Combot = ClickPopupwindow(context);
Movement = ClickPopupwindow(context);
World = ClickPopupwindow(context);
mainll.addView(Combot.getView());
mainll.addView(Movement.getView());
mainll.addView(World.getView());
Tpopup main = new Tpopup().WH(LinearLayout.LayoutParams.WRAP_CONTENT, (int) (local.H() * 0.85)).SC(true).SO(false).SF(false).ST(true).Anim("Di");
main.addView(mainll);
main.showAtLocation(mainll, Gravity.TOP, 0, 0);
}
public static Tpopup ClickPopupwindow(Context context) {
TView popupView = new TView(context).setBgD("#ffffff", 90, "TB", 0).WH((int) (local.W() * 0.2), (int) (local.H() * 0.8)).setPadding(0, 0, 50, 0);
Tpopup popup = new Tpopup().setContentView(popupView);
return popup;
}
}
```
修改后的代码中,使用了LinearLayout来实现从左到右的排列,并且添加了setPadding方法来设置间隔为50。同时,将Tpopup的ContentView设置为LinearLayout,这样就可以将三个popupwindow添加到一个LinearLayout中,从而实现从左到右排列。
阅读全文