简体   繁体   中英

Generating Simple Graphics In Java

I am just about to start porting over my iPhone application Android, but I'm finding it hard to get to grips with it.

Right now I'm trying to get the basic screens looking right before I start the back end, but have hit a brick wall with the whole, flexible layout.

I am trying to generate a simple gradient with a semi-transparent white highlight and a black bottom border to use throughout the app, but because the project will be used multiple times for many many apps with a multitude of colours, I want to do this in code rather than Photoshop.

This was easy to accomplish in OBJ-C but I've hit a brick wall before I've even started now.

Here is an example of what I am trying to achieve.

尝试的例子

Can anyone point me in the right direction?

Declare an xml with a shape and save it in your drawables folder. Then apply that drawable to your views like any other drawable/image.

graphic.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#fa8c5e"
        android:endColor="#ee9e6a"
        android:angle="90"/>
    <stroke
        android:width="1dip"
        android:color="#000000" />
</shape>

Here you can have a look at the syntax for tuning your shape.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM