Android开源:BrushView - 简单视图更改画笔大小,Alpha和颜色
xylzh46
8年前
<h2>效果</h2> <p>x<img src="https://simg.open-open.com/show/fe03e997aace0db5a0e13dba9746f91c.png"> <img src="https://simg.open-open.com/show/705c7b8bf8fbc6164d02b3d1449aae29.png"> <img src="https://simg.open-open.com/show/52a93b6f1d0d0c15486069f14f7f1a07.png"> <img src="https://simg.open-open.com/show/d21cf8d25141fed9b3a7a43153a13ede.png"></p> <h2>安装</h2> <p>In your build.gradle project</p> <pre> <code class="language-java">allprojects { repositories { ... maven { url 'https://jitpack.io' } } }</code></pre> <p>In your build.gradle app</p> <pre> <code class="language-java">dependencies { ... compile 'com.github.Andreu35:BrushView:v.1.0' ... }</code></pre> <h2>使用</h2> <p>In your layout.xml</p> <pre> <code class="language-java"><com.are.brushview.BrushView android:id="@+id/brushView" android:layout_width="220dp" android:layout_height="220dp" android:layout_gravity="center" android:layout_margin="20dp" app:brush_size="50" app:brush_alpha="255" app:brush_color="@color/colorPrimary"/></code></pre> <p>In your Activity.java</p> <pre> <code class="language-java">public class MainActivity extends AppCompatActivity { private BrushView brushView; ... @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /** * Initialize Views */ brushView = (BrushView) findViewById(R.id.brushView); ... /** * SeekBar Listeners */ seekBarSize.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { txtSize.setText(String.valueOf(progress)); brushView.setRadius(progress); } }); seekBarAlpha.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { txtAlpha.setText(String.valueOf(progress)); brushView.setAlphaValue(progress); } }); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { brushView.setColor(itemsColors.get(position).getColor()); } }); } }</code></pre> <h3>App using BrushView</h3> <p>Cards</p> <h3>许可</h3> <pre> <code class="language-java">Copyright (C) 2017 Andreu35 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</code></pre> <p> </p> <p> </p>