رفتن به مطلب
  • 0

درخواست کد میزان alpha


bahman

سوال

دوستان من طبق کد

sv.Color = Colors.rgb(46, 204, 113) 'this sets the dividers color

رنگ کاستوم لیست ویو رو تغییر دادم

حالا اگه بخوام میزان alpha الفای این و میزان گردی یا همون corner redius رو با کد تغییر بدم این کد رو چطوری تنظیمش کنم

لینک ارسال
به اشتراک گذاری در سایت های دیگر

4 پاسخ به این سوال تاکنون داده شده است

ارسال‌های توصیه شده

سلام

والا این همه کدو خودتون 2 دقیقه رو اسکرین بشینید چک کنید ببینید چه بلایی سر چشمتون میاد  :eynak: 

فونت خب به چی فونت میده ؟ به لیبل ؟ 

خب این تابع رو دستکاریش کن:

Public Sub InsertAtTextItem(Index As Int, Text As String, Value As Object)
	Dim pnl As Panel
	pnl.Initialize("")
	Dim lbl As Label
	lbl.Initialize("")
	lbl.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
	pnl.AddView(lbl, 5dip, 2dip, sv.Width - 5dip, 20dip)
	lbl.Text = Text
	lbl.TextSize = DefaultTextSize
	lbl.TextColor = DefaultTextColor
	pnl.Color = DefaultTextBackgroundColor
	Dim minHeight As Int
	minHeight = su.MeasureMultilineTextHeight(lbl, Text)
	lbl.Height = Max(50dip, minHeight)
	InsertAt(Index, pnl, lbl.Height + 2dip, Value)
End Sub
لینک ارسال
به اشتراک گذاری در سایت های دیگر

ممنونم حالا یه سوال دیگه اگه  کد کاستوم لیست ویوم باشه

'version: 1.01
Sub Class_Globals
	Private sv As ScrollView
	Private items As List
	Private panels As List
	Private dividerHeight As Float
	Private pressedDrawable As Object
	Private EventName As String
	Private CallBack As Object
	Private su As StringUtils
	Public DefaultTextSize As Int
	Public DefaultTextColor As Int
	Public DefaultTextBackgroundColor As Int
End Sub


Public Sub Initialize (vCallback As Object, vEventName As String)
	sv.Initialize2(0, "sv")
	items.Initialize
	panels.Initialize
	dividerHeight = 2dip
	EventName = vEventName
	CallBack = vCallback
	sv.Color = Colors.argb(210,46, 204, 113)
	Dim r As Reflector
	Dim idPressed As Int
   	idPressed = r.GetStaticField("android.R$drawable", "list_selector_background")
    r.Target = r.GetContext
    r.Target = r.RunMethod("getResources")
	pressedDrawable = r.RunMethod2("getDrawable", idPressed, "java.lang.int")
	DefaultTextColor = Colors.White
	DefaultTextSize = 16
	DefaultTextBackgroundColor = Colors.Black
End Sub

'Clears all items.
Public Sub Clear
	items.Clear
	panels.Clear
	sv.Panel.Height = 0
	For i = sv.Panel.NumberOfViews - 1 To 0 Step -1
		sv.Panel.RemoveViewAt(i)
	Next
End Sub

'Returns a view object that holds the list.
Public Sub AsView As View
	Return sv
End Sub

'Returns the number of items.
Public Sub GetSize As Int
	Return items.Size
End Sub

'Returns the Panel stored at the specified index.
Public Sub GetPanel(Index As Int) As Panel
	Dim p As Panel
	p = panels.get(Index) 'this is the parent panel
	Return p.GetView(0)
End Sub

'Returns the value stored at the specified index.
Public Sub GetValue(Index As Int) As Object
	Return items.get(Index)
End Sub

'Removes the item at the specified index.
Public Sub RemoveAt(Index As Int)
	Dim removePanel, p As Panel
	removePanel = panels.get(Index)
	For i = Index + 1 To items.Size - 1
		p = panels.get(i)
		p.Tag = i - 1
		p.Top = p.Top - removePanel.Height - dividerHeight
	Next
	sv.Panel.Height = sv.Panel.Height - removePanel.Height - dividerHeight
	items.RemoveAt(Index)
	panels.RemoveAt(Index)
	removePanel.RemoveView
End Sub

'Adds a text item. The item height will be adjusted based on the text.
Public Sub AddTextItem(Text As String, Value As Object)
	InsertAtTextItem(items.Size, Text, Value)
End Sub

'Inserts a text item at the specified index.
Public Sub InsertAtTextItem(Index As Int, Text As String, Value As Object)
	Dim pnl As Panel
	pnl.Initialize("")
	Dim lbl As Label
	lbl.Initialize("")
	lbl.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
	pnl.AddView(lbl, 5dip, 2dip, sv.Width - 5dip, 20dip)
	lbl.Text = Text
	lbl.TextSize = DefaultTextSize
	lbl.TextColor = DefaultTextColor
	pnl.Color = DefaultTextBackgroundColor
	Dim minHeight As Int
	minHeight = su.MeasureMultilineTextHeight(lbl, Text)
	lbl.Height = Max(50dip, minHeight)
	InsertAt(Index, pnl, lbl.Height + 2dip, Value)
End Sub

'Adds a custom item at the specified index.
Public Sub InsertAt(Index As Int, Pnl As Panel, ItemHeight As Int, Value As Object)
    
	Dim sd As StateListDrawable
    sd.Initialize
    sd.AddState(sd.State_Pressed, pressedDrawable)
    sd.AddCatchAllState(Pnl.Background)
	
	'create another panel to handle the click event
	Dim p As Panel
	p.Initialize("panel")
	p.Background = sd
	Dim cd As ColorDrawable
	cd.Initialize(Colors.Transparent, 0)
    Pnl.Background = cd
	p.AddView(Pnl, 0, 0, sv.Width, ItemHeight)
	p.Tag = Index
	
	If Index = items.Size Then
		items.Add(Value)
		panels.Add(p)
		Dim top As Int
		If Index = 0 Then top = dividerHeight Else top = sv.Panel.Height
		sv.Panel.AddView(p, 0, top, sv.Width, ItemHeight)
	Else
		Dim top As Int
		If Index = 0 Then
			top = dividerHeight
		Else
			Dim previousPanel As Panel
			previousPanel = panels.get(Index - 1)
			top = previousPanel.top + previousPanel.Height + dividerHeight
		End If

		Dim p2 As Panel
		For i = Index To panels.Size - 1
			p2 = panels.get(i)
			p2.top = p2.top + ItemHeight + dividerHeight
			p2.Tag = i + 1
		Next
		items.InsertAt(Index, Value)
		panels.InsertAt(Index, p)
		sv.Panel.AddView(p, 0, top, sv.Width, ItemHeight)
	End If
	sv.Panel.Height = sv.Panel.Height + ItemHeight + dividerHeight
	If items.Size = 1 Then sv.Panel.Height = sv.Panel.Height + dividerHeight
End Sub

'Adds a custom item.
Public Sub Add(Pnl As Panel, ItemHeight As Int, Value As Object)
	InsertAt(items.Size, Pnl, ItemHeight, Value)
End Sub

'Scrolls the list to the specified item.
Public Sub JumpToItem(Index As Int)
	Dim top As Int
	Dim p As Panel
	For i = 0 To Min(Index - 1, items.Size - 1)
		p = panels.get(i)
		top = top + p.Height + dividerHeight
	Next
	sv.ScrollPosition = top
	'The scroll position doesn't always gets updated without two calls to DoEvents
	DoEvents
	sv.ScrollPosition = top
	DoEvents
End Sub

Private Sub sv_ScrollChanged(Position As Int)
	If SubExists(CallBack, EventName & "_Position") Then
 
		CallSub2(CallBack, EventName & "_Position",Position)
	End If
End Sub

Public Sub getPanelHeight
 Return sv.Panel.Height
End Sub

Public Sub getHeight As Int
Return sv.Height
End Sub

Private Sub Panel_Click
	If SubExists(CallBack, EventName & "_ItemClick") Then
		Dim v As View
		v = Sender
		CallSub3(CallBack, EventName & "_ItemClick", v.Tag, items.get(v.Tag))
	End If
End Sub

'Returns the index of the item that holds the given view.
Public Sub GetItemFromView(v As View)
	Dim r As Reflector
	Dim parent, current As Object
	parent = v
	Do While (parent Is Panel) = False Or sv.Panel <> parent
		current = parent
		r.Target = current
		parent = r.RunMethod("getParent")
	Loop
	v = current
	Return v.Tag
End Sub

چطور میتونم فونتشو سفارشی کنم ممنون میشم تو کد بالا جاش بدین چون روشایی که بلدم رو میزنم نمیشه تو دیزاینر هم ندارم فونت بدم بهش

با typeface چیز کردم نشد

لینک ارسال
به اشتراک گذاری در سایت های دیگر

بایگانی شده

این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.

  • کاربران آنلاین در این صفحه   0 کاربر

    • هیچ کاربر عضوی،در حال مشاهده این صفحه نیست.
×
×
  • اضافه کردن...