Android弧形效果

1. 引言

 

    在开发过程中有这样一个需求,实现右弧形效果,考虑了一下,用ListView实现,效果图如下:

   

2. 功能实现

 

    (1) 主布局(main.xml)实现:  

 

    (2) 主Activity实现:package com.flora; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; public class ArcActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView arcList = (ListView) findViewById(R.id.arcList); arcList.setDividerHeight(0); arcList.setAdapter(new ArcAdapter()); } private class ArcAdapter extends BaseAdapter { private int [] mFoxTypePosition = {10, 50, 100, 150, 100, 50, 10}; private int [] mFoxTypeColor = {Color.BLUE, Color.CYAN, Color.DKGRAY, Color.GREEN, Color.LTGRAY, Color.MAGENTA, Color.RED}; @Override public int getCount() { return 7; } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout foxTypeComponent = new LinearLayout(ArcActivity.this); TextView foxTypeComponentContent = new TextView(ArcActivity.this); foxTypeComponentContent.setWidth(50); foxTypeComponentContent.setHeight(50); foxTypeComponentContent.setBackgroundColor(mFoxTypeColor[position]); foxTypeComponent.setPadding(mFoxTypePosition[position], 0, 0, 0); foxTypeComponent.addView(foxTypeComponentContent); return foxTypeComponent; } } }

你可能感兴趣的:(Android基础)