嘿 我刚写了一个横向进度条。进度条获取此后台资源:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progress_bg" />
</item>
<item android:id="@android:id/progress" android:gravity="center">
<clip>
<shape>
<corners android:radius="5dip" />
<solid android:color="#FFF" />
</shape>
</clip>
</item>
这样可以正常工作,但白色进度与背景高度相同。但是我希望进度小于进度条的背景,因为thre背景有一个不应该重叠的边界。
有什么想法吗? 感谢
答案 0 :(得分:2)
还有:
<item android:id="@android:id/secondaryProgress"></item>
你也改变了吗?
答案 1 :(得分:1)
http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList
您可以尝试将android:top
,android:left
,android:right
和android:bottom
添加到白色进度条item
,以便向条形图添加填充。
<item android:id="@android:id/progress" android:gravity="center"
android:top="2dp" android:left="2dp" android:right="2dp" android:bottom="2dp">
<clip>
<shape>
<corners android:radius="5dip" />
<solid android:color="#FFF" />
</shape>
</clip>
</item>
答案 2 :(得分:1)
完整的xml是:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progress_bg" />
</item>
<item android:id="@android:id/secondaryProgress" android:gravity="center">
<clip>
<shape>
<corners android:radius="5dip" />
<solid android:color="#FFF" />
</shape>
</clip>
</item>
干杯
答案 3 :(得分:0)
嗨尝试添加没有颜色的笔触(不透明度最大) 我用渐变进度条尝试了这段代码:
class PLCH_DLL_DECL CEasyPLCHandler : public CPLCHandler
{
public:
CEasyPLCHandler(RTS_HANDLE hLogFile = RTS_INVALID_HANDLE);
CEasyPLCHandler(PlcConfig *pPlcConfig, PlcDeviceDesc *pDeviceDesc, RTS_HANDLE hLogFile = RTS_INVALID_HANDLE);
CEasyPLCHandler(unsigned long ulId, char *pszIniFile, RTS_HANDLE hLogFile = RTS_INVALID_HANDLE);
CEasyPLCHandler(char *pszPlcName, char *pszIniFile, RTS_HANDLE hLogFile = RTS_INVALID_HANDLE);
virtual ~CEasyPLCHandler(void);
// See PLCConfig.h for defines of pszProtocol
// e.g. #define PLCC_DN_TCPIP_L2ROUTE "Tcp/Ip (Level 2 Route)"
virtual long ConnectTcpipViaGateway(char *pszGatewayIP, char *pszPlcIP, char *pszProtocol = PLCC_DN_TCPIP_L2ROUTE, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT, unsigned long ulPort = 1200);
virtual long ConnectRs232ViaGateway(char *pszGatewayIP, short sPort, unsigned long ulBaudrate, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectRs232ViaGatewayEx(char *pszGatewayIP, short sPort, unsigned long ulBaudrate, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT, EXT_RS232_PARAMStyp *pExtParams = NULL);
virtual long ConnectTcpipViaArti(char *pszPlcIP, char *pszProtocol = PLCC_DN_TCPIP_L2ROUTE, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT, unsigned long ulPort = 1200);
virtual long ConnectRs232ViaArti(short sPort, unsigned long ulBaudrate, int bMotorola = 0, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectToSimulation(char *pszSdbFile, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectViaGateway3(char *pszGatewayIP, char *pszAddress, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectViaGateway3Ex(char *pszGatewayIP, unsigned long ulPort, char *pszAddress, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectViaArti3(char *pszAddress, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
virtual long ConnectToSimulation3(char *pszSdb3XmlFile, int bLoadSymbols = 1, unsigned long ulTimeout = PLCHANDLER_USE_DEFAULT);
// Attention: The structure of the service must be known in detail!
// An erroneous service might cause a crash of the PLC!
// Send own service to plc and receive reply
virtual long SyncSendService(/*[In]*/ unsigned char *pbySend, /*[In]*/ unsigned long ulSendSize, /*[Out]*/ unsigned char **ppbyRecv, /*[Out]*/ unsigned long *pulRecvSize);
// Send own service to plc
virtual long AsyncSendService(/*[Out]*/ int *piInvokeId, /*[In]*/ unsigned char *pbySend, /*[In]*/ unsigned long ulSendSize, /*[In]*/ CPLCHandlerCallback *pAsyncServiceCallback = NULL);
// Get service reply
virtual long AsyncGetServiceReply(/*[In]*/ int *piInvokeId, /*[Out]*/ unsigned char **ppbyRecv, /*[Out]*/ unsigned long *pulRecvSize, long *plServiceResult);
// Get SessionId for Device services (only used for GW3 and ARTI3)
virtual unsigned long GetDeviceSessionId(void);
};
所以你的代码应该是这样的:
pPLCHandler = new CEasyPLCHandler(RTS_INVALID_HANDLE);
为我工作,希望它适合你:D