我想设计一个包含一个按钮的布局,当我们点击按钮时,它会在屏幕的顶部打开一个像键盘一样从底部打开的布局。
但不知道怎么做?
请分享您的想法。
布局的屏幕截图:
当我点击该下拉按钮时,另一个布局将来自下载,其大小为虚拟键盘。
谢谢, Ammu
答案 0 :(得分:4)
在使用Example时尝试使用SlidingDrawer,有关这方面的更多信息显然是Android Docs
答案 1 :(得分:2)
动画可以帮助您做到这一点:
private void initPopup()
{
final TransparentPanel popup = (TransparentPanel) findViewById(R.id.popup_window);
// Start out with the popup initially hidden.
popup.setVisibility(View.GONE);
animShow = AnimationUtils.loadAnimation( this, R.anim.popup_show);
animHide = AnimationUtils.loadAnimation( this, R.anim.popup_hide);
final Button showButton = (Button) findViewById(R.id.show_popup_button);
final Button hideButton = (Button) findViewById(R.id.hide_popup_button);
showButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
popup.setVisibility(View.VISIBLE);
popup.startAnimation( animShow );
showButton.setEnabled(false);
hideButton.setEnabled(true);
}});
hideButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
popup.startAnimation( animHide );
showButton.setEnabled(true);
hideButton.setEnabled(false);
popup.setVisibility(View.GONE);
}});
final TextView locationName = (TextView) findViewById(R.id.location_name);
final TextView locationDescription = (TextView) findViewById(R.id.location_description);
locationName.setText("Animated Popup");
locationDescription.setText("Animated popup is created by Arun nu solla mattaen"
+ " Transparent layout is used on this example, and animation xml is also used"
+ " on this example. Have a Good day guys.");
}
请参阅此example
希望这会对你有所帮助。