Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何以编程方式设置 layout_gravity?
我需要设置按钮的位置或LEFT在特定布局中,我使用了但是,它设置了按钮文本的重力。CENTERRIGHTmyButton.setGravity(Gravity.LEFT);
LEFT
CENTER
RIGHT
myButton.setGravity(Gravity.LEFT);
我通过将您的标题放在搜索栏中找到了这一点。简短版本:使用LayoutParams
LayoutParams