- 浏览: 47746 次
- 性别:
- 来自: 上海
最新评论
文章列表
对图片的截取,按照1/3比例:
int bmpWidth = bitmap.getWidth();
int bmpHeight = bitmap.getHeight();
int h = bmpHeight * mScreenWidth / bmpWidth;
//截图(按1/3比例)
int resultHeight = (Integer) (bmpWidth * 210/320);
bitmap= Bitmap.createBitmap(bitmap, 0, bmpHeight / 3
- resultHeight / 2, bmpWidth, re ...
使用ViewPager实现图片的滑动。
//将 R.drawable里面的图片资源转成换Bitmap型
Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);
Bitmap newb = Bitmap.createBitmap( 300, 300, Config.ARGB_8888 );
Canvas canvasTemp = new Canvas( newb );
canvasTemp.drawBitmap(bmp, 50, 50, p);
InputStream is = getResour ...
Spinner 设置下拉框
- 博客分类:
- android
第一步:定义声明
setSpinner(spinnerSex, R.array.baby_sex, sexPos);
第二步:调用方法
private void setSpinner(Spinner spinner, int array, int pos) {
// 将可选内容与ArrayAdapter连接起来
ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(
this, array, android.R.layout.simple_spinner_item);
// 设置 ...
1、HttpPost
复制代码 代码如下:
try{
//创建连接
HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
//设置参数,仿html表单提交
List<NameValuePair> paramList = new ArrayList<NameValuePair>();
BasicNameValuePair param = new BasicNameValuePair("param1",paramValue);
paramLi ...
public static Bitmap ResizeBitmap(Bitmap bitmap, int newWidth) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float temp = ((float) height) / ((float) width);
int newHeight = (int) ((newWidth) * temp);
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ( ...
第一种方法:
<HorizontalScrollView
android:id="@+id/hs_tab"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@color/white"
android:layout_below="@id/activity_bbs_topc_list_top"
...
package com.example.scroll;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.example.scroll.GridAdapter.ViewHolder;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClic ...
dynamic_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="ve ...
flipper.setLongClickable(true);
flipper.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Log.d("00", "------flipper.setOnTouchListener---------");
// onFli ...