Android開源:BrushView - 簡單視圖更改畫筆大小,Alpha和顏色
效果
x
安裝
In your build.gradle project
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
In your build.gradle app
dependencies {
...
compile 'com.github.Andreu35:BrushView:v.1.0'
...
}
使用
In your layout.xml
<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"/>
In your Activity.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>
App using BrushView
Cards
許可
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>
本文由用戶 xylzh46 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!