<View xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:layout_height=“1px”
android:background=“#cbcbcb” />
<View xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“1px”
android:layout_height=“match_parent”
android:background=“#cbcbcb” />
下面是动态生成布局的实现方式:
private void initUI() {
setContentView(R.layout.activity_main);
//setTitle(R.string.button_service_upload_picture);
//showBackwardView(R.string.button_backward, true);
//showForwardView(R.string.button_upload,true);
//最顶层父布局
mLayout = (ViewGroup) findViewById(R.id.layout_container);
final int count = 9; //9格
final int rowCount = (count + 2) / 3;
for (int i = 0; i < rowCount; i++) {
if (i != 0) {
//加载横向布局线条
View.inflate(this, R.layout.layout_line_horizonal, mLayout);
}
//创建布局对象,设置按下颜色
final LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setBackgroundResource(R.drawable.row_selector);
for (int j = 0; j < 3; j++) {
if (j != 0) {
//加载内层纵向布局线条
View.inflate(this, R.layout.layout_line_vertical, linearLayout);
}
ImageButton imageButton = new ImageButton(this);
imageButton.setBackgroundResource(R.drawable.row_selector);
imageButton.setTag(TAG);
imageButton.setOnClickListener(this);
imageButton.setEnabled(false);
LinearLayout.LayoutParams layoutParams =
new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f);
//添加到linearLayout布局中
linearLayout.addView(imageButton, layoutParams);
//将imageButton对象添加到列表
mImageButtonList.add(imageButton);
}
DisplayManager manager = DisplayManager.getInstance();
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, manager.dipToPixel(100));
//将View添加到总父布局
mLayout.addView(linearLayout, layoutParams);
}
//外层设置ImageButton属性
final ImageButton currentImageButton = mImageButtonList.get(mCurrent);
currentImageButton.setImageResource(R.drawable.ic_add_picture);
currentImageButton.setScaleType(ScaleType.CENTER);
currentImageButton.setEnabled(true);
}
图片上传功能:
private class UploadPictureTask extends AsyncTask<List, Integer, String> {
/* (non-Javadoc)
• @see android.os.AsyncTask#doInBackground(Params[])
*/
@Override
protected String doInBackground(List… params) {
final List pictureList = params[0];
for (int i = 0, len = pictureList.size(); i < len; i++) {
final File file = new File(pictureList.get(i));
//final String response = ApacheHttpUtils.post(mUrlPrefix + “/upload”, new File[] {file});
// 解析,存储
//final UploadInfo upload = new UploadParser().parse(response).getData();
/*if (upload != null) {
final String url = upload.getUrl();
if (url != null) {
mPictureUrlList.add(url);
}
}*/
publishProgress(i);
}
return null;
}
android BRAVH 动态切换垂直网格
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:python定义有参函数句子
下一篇:MySQL作为持久化存储优势
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Java-RuoYi动态切换据库连接
Java-RuoYi动态切换据库连接
sql System List -
echarts-去掉垂直网格线
1、问题背景 设计一条统计人数的折线,其中网格线没有垂直线2、实现源码(1)有垂直网格线 echarts-去掉垂直网格线 (2)无垂直网格线 echarts-去...
html ico javascript jquery 折线 -
ios使用的编码格式
邓氏编码(D-U-N-S Number)申请详细流程 1、 https://developer.apple.com,进入开发者中心登录页面,输入账号和密码登录。 2、 点
ios使用的编码格式 发邮件 登录页面 Code